[web2py] Need help with selecting multiple rows into a single row

2012-01-20 Thread Adi

I am trying to export all rows from two tables, (e.g. purchase orders, and 
items) into a csv file, but if possible would like to export a single row 
per each purchase order (with belonging items divided into separate columns 
of the same row). I'm using MySQL, if it makes the difference.

I read some comments about using the Expression or a function (from 
gluon.sql import Expression), but don't know how to go about it. Any advise?

Thanks,
Adnan

>>> rows = db(db.purchase_order.id>0).select(db.purchase_order.po_number, 
db.item.id, left=db.item.on(db.purchase_order.id==db.item.po_id))
>>> print rows

results:
purchase_order.po_number,item.id
201201120001,31
201201120001,41
201201120001,51
201201120001,61
201201160004,111
201201170005,151
201201006,161

would prefer to have it like this: 
201201120001,31,41,51,61
201201160004,111
201201170005,151
201201006,161



[web2py] CUSTOMIZE SQLFORM.grid

2012-01-20 Thread cyber

I need not VIEW / EDIT / DELETE records in selected db table.
I want user to be redirected to another page after clicking some link.
But I have no ideas of how to customise grid.

Is it possible to add some additional link to each record in
SQLFORM.GRID?


[web2py] Re: Sending simplified email from web2py

2012-01-20 Thread pbreit
Should work fine. What does your code look like?

http://web2py.com/books/default/chapter/29/8#Simple-text-email


Re: [web2py] PSTV [Paradigm Shift Television] Powered by Inclusion

2012-01-20 Thread Andrew Evans
Yes was made by me and a partner/friend of mine


and ty

On Fri, Jan 20, 2012 at 8:52 PM, Bruno Rocha  wrote:

> looks very nice on mobile! congrats!
>
>
> On Sat, Jan 21, 2012 at 12:42 AM, Andrew Evans 
> wrote:
>
>> Wondering if this site can be included in the powered by web2py
>>
>> www.paradigmshift.tv
>>
>> *cheers
>>
>> Andrew
>>
>
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


Re: [web2py] PSTV [Paradigm Shift Television] Powered by Inclusion

2012-01-20 Thread Bruno Rocha
looks very nice on mobile! congrats!

On Sat, Jan 21, 2012 at 12:42 AM, Andrew Evans wrote:

> Wondering if this site can be included in the powered by web2py
>
> www.paradigmshift.tv
>
> *cheers
>
> Andrew
>



-- 

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


[web2py] Re: PSTV [Paradigm Shift Television] Powered by Inclusion

2012-01-20 Thread Anthony
Just added it. Very nice. :-)

Anthony

On Friday, January 20, 2012 9:42:48 PM UTC-5, Andrew wrote:
>
> Wondering if this site can be included in the powered by web2py
>
> www.paradigmshift.tv
>
> *cheers
>
> Andrew
>


[web2py] Re: PSTV [Paradigm Shift Television] Powered by Inclusion

2012-01-20 Thread Massimo Di Pierro
It indeed appears to be web2py powered. Did you make it?

On Jan 20, 8:42 pm, Andrew Evans  wrote:
> Wondering if this site can be included in the powered by web2py
>
> www.paradigmshift.tv
>
> *cheers
>
> Andrew


[web2py] Re: passing navigational links in the header and ajax woes

2012-01-20 Thread Massimo Di Pierro
There is nothing wrong in the /1/2/3 but I do not see where you use
that in the code. I see a lot of repeated and un-necessary selects. I
suspect you can simplify your code a lot.

Can you explain in words what you want to achieve?



On Jan 19, 10:53 pm, web-dev-m  wrote:
> Currently, in my application, I am passing navigational links in the
> header, such as /app/controller/view/1/2/3
>
> Where 1/2/3 are things the controller and view use to set the correct
> page.
>
> In my application, I am finding two problems with this.  First is
> security.  Although I have written validation on my controllers (I
> hope), I just worry that with more users some malicious person will
> find a way to get access they shouldn't.
>
> Second and more urgent is my application broke when I tried to write
> my first ajax function, I assume because the navigational variables
> are competing with the ajax variables somehow.  I say this because
> when I make the controller empty and just return a dict everything
> works as normal.  However, when I have the controller look for
> variables in request.vars and I then try to call an ajax function, it
> breaks hideously.
>
> I don't claim to be a great programmer, so it could definitely be a
> convention I am not following.
>
> Has anyone had this problem before?  How did you solve it? Should I
> pass my request.vars into the session and then have the view call
> them?
>
>  I read in the book that I can do ajax trapping and I haven't tried
> that yet, but I didn't think it would be necessary since I could make
> it work without it.  I will try it, but regardless I would love to get
> some feedback.
>
> for clarity, my code causing problems is below:
>
> def my_func():
>     if request.args:
>         #First, I check to see if there is a record, if there is, I
> get some information.
>         check=db(db.mydb.id==request.args(0)).select().first()
>         if check !=None:
>             records=db(db.mydb.id==request.args(0)).select()
>             row = db(db.mydb.id==request.args(0)).select().first()
>             counter=len(records)
>         #if it isnt, I make it with a function
>         else:
>             row = db(db.mydb.id==request.args(0)).select().first()
>             my_id=row.id
>             (filename, stream) =
> db.mydb.myfield.retrieve(row.resourcefield)
>             myfunc(id,filename,stream)
>             records=db(db.mydb.id==request.args(0)).select()
>             counter=len(records)
>         pass
>     #if there is no specific document request, generate a list of
> available files
>     else:
>         redirect(URL('mycontroller','this_function'))
>     return(counter=counter, records=records, row=row)
>
> def myajaxfunc():
>     form=SQLFORM(db.mydb2, _action="myajaxfunc")
>     if form.errors:
>         session.flash="Error: " + str(form.errors)
>     return XML(form)
>
> my view:
>
> {{for i in range(1,5):}}
>     Click me to add a note
>     
> {{pass}}


Re: [web2py] Re: Is it me or what?

2012-01-20 Thread Alexandre Andrade
I just cant recover my login/password and my only solution was marks ourway
emails as spam, since i cant optout


2012/1/20 Farsheed Ashouri 

> Ourway is under development dude and it's going to be a large scale social
> network system late 2012.
> Check out it's blogging system for 
> *example*
> .
> http://ourway.ir/blog
>



-- 
Atenciosamente


Alexandre Andrade
Hipercenter.com Classificados Gratuitos


[web2py] Re: my gae+web2py app: feed9 (like reddit)

2012-01-20 Thread Changju
Good job sungchi!

On 1월2ㄴ0일, 오후8시38분, sungchi  wrote:
> source:https://github.com/sungchi/feed9
> link:http://www.feed9.com/(korean)
>
> based reddish source (now RedditClone 
> :https://github.com/mdipierro/web2py-appliances/tree/master/RedditClone
> )
> UI :http://twitter.github.com/bootstrap/
>
> Well .. Just think like Reddit
> Thank you


[web2py] PSTV [Paradigm Shift Television] Powered by Inclusion

2012-01-20 Thread Andrew Evans
Wondering if this site can be included in the powered by web2py

www.paradigmshift.tv

*cheers

Andrew


[web2py] Re: passing navigational links in the header and ajax woes

2012-01-20 Thread web-dev-m
To pass information from one controller to another.  I assume it is
poor programming practice then? I taught myself web programming on
web2py, so I have never had formal training and it was the easiest way
I could think of to do this.  I think I have seen it in other posted
examples as well.

On Jan 20, 12:14 pm, Cliff  wrote:
> > Currently, in my application, I am passing navigational links in the
> > header, such as /app/controller/view/1/2/3
>
> > Where 1/2/3 are things the controller and view use to set the correct
> > page.
>
> Why are you doing this?
>
> On Jan 19, 11:53 pm, web-dev-m  wrote:
>
>
>
>
>
>
>
> > Currently, in my application, I am passing navigational links in the
> > header, such as /app/controller/view/1/2/3
>
> > Where 1/2/3 are things the controller and view use to set the correct
> > page.
>
> > In my application, I am finding two problems with this.  First is
> > security.  Although I have written validation on my controllers (I
> > hope), I just worry that with more users some malicious person will
> > find a way to get access they shouldn't.
>
> > Second and more urgent is my application broke when I tried to write
> > my first ajax function, I assume because the navigational variables
> > are competing with the ajax variables somehow.  I say this because
> > when I make the controller empty and just return a dict everything
> > works as normal.  However, when I have the controller look for
> > variables in request.vars and I then try to call an ajax function, it
> > breaks hideously.
>
> > I don't claim to be a great programmer, so it could definitely be a
> > convention I am not following.
>
> > Has anyone had this problem before?  How did you solve it? Should I
> > pass my request.vars into the session and then have the view call
> > them?
>
> >  I read in the book that I can do ajax trapping and I haven't tried
> > that yet, but I didn't think it would be necessary since I could make
> > it work without it.  I will try it, but regardless I would love to get
> > some feedback.
>
> > for clarity, my code causing problems is below:
>
> > def my_func():
> >     if request.args:
> >         #First, I check to see if there is a record, if there is, I
> > get some information.
> >         check=db(db.mydb.id==request.args(0)).select().first()
> >         if check !=None:
> >             records=db(db.mydb.id==request.args(0)).select()
> >             row = db(db.mydb.id==request.args(0)).select().first()
> >             counter=len(records)
> >         #if it isnt, I make it with a function
> >         else:
> >             row = db(db.mydb.id==request.args(0)).select().first()
> >             my_id=row.id
> >             (filename, stream) =
> > db.mydb.myfield.retrieve(row.resourcefield)
> >             myfunc(id,filename,stream)
> >             records=db(db.mydb.id==request.args(0)).select()
> >             counter=len(records)
> >         pass
> >     #if there is no specific document request, generate a list of
> > available files
> >     else:
> >         redirect(URL('mycontroller','this_function'))
> >     return(counter=counter, records=records, row=row)
>
> > def myajaxfunc():
> >     form=SQLFORM(db.mydb2, _action="myajaxfunc")
> >     if form.errors:
> >         session.flash="Error: " + str(form.errors)
> >     return XML(form)
>
> > my view:
>
> > {{for i in range(1,5):}}
> >     Click me to add a note
> >     
> > {{pass}}


Re: [web2py] Re: Select X random from returned list

2012-01-20 Thread Bruce Wade
Ok thanks Massimo.

On Fri, Jan 20, 2012 at 5:09 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> yes. :-)
>
> On Jan 20, 5:48 pm, Bruce Wade  wrote:
> > Would this be the best approach:
> > todays_ids = set(used_ad_ids)
> > unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
> > unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
> > unseen_ads_query = unseen_ads_query(self.db.ads.viewable == True)
> > unseen_ads_query = unseen_ads_query(self.db.ads.accepted == True)
> > *unseen_ads = unseen_ads_query.select(orderby='',
> > limitby=(0,5))*
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Jan 20, 2012 at 3:34 PM, Bruce Wade 
> wrote:
> > > Hi,
> >
> > > I have selected a list of objects from the database, which is working.
> Now
> > > I would like to select 5 random rows from the list and ideally only
> hit the
> > > database once to get them 5 random rows.
> >
> > > todays_ids = set(used_ad_ids)
> > > unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
> > > unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
> > > unseen_ads_query = unseen_ads_query(self.db.ads.viewable ==
> True)
> > > unseen_ads_query = unseen_ads_query(self.db.ads.accepted ==
> True)
> > > unseen_ads = unseen_ads_query.select()
> >
> > > # now pull 5 random rows out of the returned rows, each time
> this
> > > method is called the random 5 should always be different from the last
> call.
> > > # Can this be done before the last select() statement and
> allow to
> > > use limit(5) so the database isn't hit so hard if there were 1,000,000
> > > results in the select() and I only need 5 random out of the 1,000,000
> >
> > > return unseen_ads
> >
> > > Also please let me know if their is a more efficient way to do the
> above
> > > query.
> >
> > > --
> > > --
> > > Regards,
> > > Bruce Wade
> > >http://ca.linkedin.com/in/brucelwade
> > >http://www.wadecybertech.com
> > >http://www.warplydesigned.com
> > >http://www.fitnessfriendsfinder.com
> >
> > --
> > --
> > 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


[web2py] Re: Select X random from returned list

2012-01-20 Thread Massimo Di Pierro
yes. :-)

On Jan 20, 5:48 pm, Bruce Wade  wrote:
> Would this be the best approach:
>         todays_ids = set(used_ad_ids)
>         unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
>         unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
>         unseen_ads_query = unseen_ads_query(self.db.ads.viewable == True)
>         unseen_ads_query = unseen_ads_query(self.db.ads.accepted == True)
>         *unseen_ads = unseen_ads_query.select(orderby='',
> limitby=(0,5))*
>
>
>
>
>
>
>
>
>
> On Fri, Jan 20, 2012 at 3:34 PM, Bruce Wade  wrote:
> > Hi,
>
> > I have selected a list of objects from the database, which is working. Now
> > I would like to select 5 random rows from the list and ideally only hit the
> > database once to get them 5 random rows.
>
> >         todays_ids = set(used_ad_ids)
> >         unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
> >         unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
> >         unseen_ads_query = unseen_ads_query(self.db.ads.viewable == True)
> >         unseen_ads_query = unseen_ads_query(self.db.ads.accepted == True)
> >         unseen_ads = unseen_ads_query.select()
>
> >         # now pull 5 random rows out of the returned rows, each time this
> > method is called the random 5 should always be different from the last call.
> >         # Can this be done before the last select() statement and allow to
> > use limit(5) so the database isn't hit so hard if there were 1,000,000
> > results in the select() and I only need 5 random out of the 1,000,000
>
> >         return unseen_ads
>
> > Also please let me know if their is a more efficient way to do the above
> > query.
>
> > --
> > --
> > Regards,
> > Bruce Wade
> >http://ca.linkedin.com/in/brucelwade
> >http://www.wadecybertech.com
> >http://www.warplydesigned.com
> >http://www.fitnessfriendsfinder.com
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: Select X random from returned list

2012-01-20 Thread Bruce Wade
Would this be the best approach:
todays_ids = set(used_ad_ids)
unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
unseen_ads_query = unseen_ads_query(self.db.ads.viewable == True)
unseen_ads_query = unseen_ads_query(self.db.ads.accepted == True)
*unseen_ads = unseen_ads_query.select(orderby='',
limitby=(0,5))*

On Fri, Jan 20, 2012 at 3:34 PM, Bruce Wade  wrote:

> Hi,
>
> I have selected a list of objects from the database, which is working. Now
> I would like to select 5 random rows from the list and ideally only hit the
> database once to get them 5 random rows.
>
> todays_ids = set(used_ad_ids)
> unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
> unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
> unseen_ads_query = unseen_ads_query(self.db.ads.viewable == True)
> unseen_ads_query = unseen_ads_query(self.db.ads.accepted == True)
> unseen_ads = unseen_ads_query.select()
>
> # now pull 5 random rows out of the returned rows, each time this
> method is called the random 5 should always be different from the last call.
> # Can this be done before the last select() statement and allow to
> use limit(5) so the database isn't hit so hard if there were 1,000,000
> results in the select() and I only need 5 random out of the 1,000,000
>
> return unseen_ads
>
> Also please let me know if their is a more efficient way to do the above
> query.
>
> --
> --
> 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] Select X random from returned list

2012-01-20 Thread Bruce Wade
Hi,

I have selected a list of objects from the database, which is working. Now
I would like to select 5 random rows from the list and ideally only hit the
database once to get them 5 random rows.

todays_ids = set(used_ad_ids)
unseen_ads_query = self.db(~self.db.ads.id.belongs(todays_ids))
unseen_ads_query = unseen_ads_query(self.db.ads.points >= 0)
unseen_ads_query = unseen_ads_query(self.db.ads.viewable == True)
unseen_ads_query = unseen_ads_query(self.db.ads.accepted == True)
unseen_ads = unseen_ads_query.select()

# now pull 5 random rows out of the returned rows, each time this
method is called the random 5 should always be different from the last call.
# Can this be done before the last select() statement and allow to
use limit(5) so the database isn't hit so hard if there were 1,000,000
results in the select() and I only need 5 random out of the 1,000,000

return unseen_ads

Also please let me know if their is a more efficient way to do the above
query.

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


[web2py] Re: writable depending on another field

2012-01-20 Thread Massimo Di Pierro

It does not work because this db.t.f1 is a field (a column) not a
value (true or false).

I guess what you want is make the second field readable or writable
depending on which record you are looking at. For example it makes no
sense if you are inserting a new record, should the second field be
editable or not?

That requires that you do it in controllers for example:

def edit_t():
 record = db.t(request.args(0))
 if record: db.t.f2.writable = record.f1
 else db.t2.writable = true
 form =  SQLFORM(db.t, record).process()
 return dict(form=form)



On Jan 20, 5:12 pm, Martin Weissenboeck  wrote:
> Hi,
>
> I want to have a model like
>
> db.define_table("t",
>     Field('f1', 'boolean'),
>     Field('f2', 'boolean', writable = db.t.f1),
>   )
>
> Of course, this does not work, but how could it be written?
>
> Regards, Martin


[web2py] Re: cPickle TypeError

2012-01-20 Thread Bruce Wade
Never mind I found my problem, I was using "load" instead of "load*s*"

On Fri, Jan 20, 2012 at 2:48 PM, Bruce Wade  wrote:

> Hi I am trying to use cPickle to store data in the database when I try to
> load the pickle data later I am getting the following error:
>
> Traceback (most recent call last):
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw/gluon/restricted.py", line 
> 204, in restricted
>
> exec ccode in environment
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw/applications/welcome/controllers/adviewer.py"
>  , line 
> 134, in 
>
>   File "/home/bruce/Development/bossteam_dev/projects/yaw/gluon/globals.py", 
> line 172, in 
>
> self._caller = lambda f: f()
>
>   File "/home/bruce/Development/bossteam_dev/projects/yaw/gluon/tools.py", 
> line 2533, in f
>
> return action(*a, **b)
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw/applications/welcome/controllers/adviewer.py"
>  , line 61, 
> in viewads
>
> ads_to_view = adviewer_engine.getUrls()
>
>   File "applications/welcome/modules/adviewer_api.py", line 43, in getUrls
>
> ads_viewed = cPickle.load(today_ads.adsviewed)
> TypeError: argument must have 'read' and 'readline' attributes
>
>
> Here is my code for storing:
>
> ads = []
> random_ads = self._getRandomUrls([])
> if random_ads:
> for index, url in enumerate(random_ads):
> ads.append({
> 'index': index,
> 'id': url['id'],
> 'url': url['url'],
> 'valid': '',
> 'suburlcount': '',
> 'viewcanceled': '',
> 'timestart': '',
> 'timeend': '',
> 'rating': ''
> })
> ads_to_view = cPickle.dumps(ads)
>
> # Create todays ads to view
> self.db.viewedads.insert(member_id=member, date=date, 
> adsviewed=ads_to_view)
>
> Now when I try to use cPickle.loads() that is where I get the error above:
>
> today_ads = self.db(self.db.viewedads.member_id == member, date == 
> date).select().first()ads_viewed = cPickle.load(today_ads.adsviewed)
>
> print today_ads.adsviewed # This works as expected shows the cPickle data
>
>
> Is there something I am missing to get this to work with web2py?
>
>
> --
> --
> 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] writable depending on another field

2012-01-20 Thread Martin Weissenboeck
Hi,

I want to have a model like

db.define_table("t",
Field('f1', 'boolean'),
Field('f2', 'boolean', writable = db.t.f1),
  )


Of course, this does not work, but how could it be written?

Regards, Martin


[web2py] Re: Need help with drag-n-drop using jQuery

2012-01-20 Thread Chris May
Hello, Frank, Welcome to web2py! I am also relatively new to web 
application development.

I threw your code into a new application, and I get very fast responses, 
usually in a fraction of a second. I don't know exactly why I have a 
dramatic difference in speed, but I do notice one thing that might aid in 
the development of the application.

They way you implemented your drag-and-drop, the application sends a 
request to the server on every 'focus' and 'mouseup' event. It would be 
better to have the JavaScript handle the drag-and-drop in the browser and 
send only the changes to the server.


[web2py] cPickle TypeError

2012-01-20 Thread Bruce Wade
Hi I am trying to use cPickle to store data in the database when I try to
load the pickle data later I am getting the following error:

Traceback (most recent call last):
  File "/home/bruce/Development/bossteam_dev/projects/yaw/gluon/restricted.py",
line 204, in restricted
exec ccode in environment
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw/applications/welcome/controllers/adviewer.py"
,
line 134, in 
  File "/home/bruce/Development/bossteam_dev/projects/yaw/gluon/globals.py",
line 172, in 
self._caller = lambda f: f()
  File "/home/bruce/Development/bossteam_dev/projects/yaw/gluon/tools.py",
line 2533, in f
return action(*a, **b)
  File 
"/home/bruce/Development/bossteam_dev/projects/yaw/applications/welcome/controllers/adviewer.py"
,
line 61, in viewads
ads_to_view = adviewer_engine.getUrls()
  File "applications/welcome/modules/adviewer_api.py", line 43, in getUrls
ads_viewed = cPickle.load(today_ads.adsviewed)
TypeError: argument must have 'read' and 'readline' attributes


Here is my code for storing:

ads = []
random_ads = self._getRandomUrls([])
if random_ads:
for index, url in enumerate(random_ads):
ads.append({
'index': index,
'id': url['id'],
'url': url['url'],
'valid': '',
'suburlcount': '',
'viewcanceled': '',
'timestart': '',
'timeend': '',
'rating': ''
})
ads_to_view = cPickle.dumps(ads)

# Create todays ads to view
self.db.viewedads.insert(member_id=member, date=date,
adsviewed=ads_to_view)

Now when I try to use cPickle.loads() that is where I get the error above:

today_ads = self.db(self.db.viewedads.member_id == member, date ==
date).select().first()ads_viewed = cPickle.load(today_ads.adsviewed)

print today_ads.adsviewed # This works as expected shows the cPickle data


Is there something I am missing to get this to work with web2py?


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


[web2py] Book typo

2012-01-20 Thread Johann Spies
db(db.dog).select(dictinct = db.dog.name[:3])

should be

db(db.dog).select(distinct = db.dog.name[:3])


Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Re: Query not in

2012-01-20 Thread Bruce Wade
Thanks Anthony, that was exactly what I was looking for.

On Fri, Jan 20, 2012 at 1:33 PM, Anthony  wrote:

> How about:
>
> db(~db.table.id.belongs([2, 10, 5, 8])).select()
>
> Anthony
>
> On Friday, January 20, 2012 4:23:03 PM UTC-5, Detectedstealth wrote:
>>
>> Hi,
>>
>> How can I make web2py query for all results that are not in a list of ids?
>>
>> IE:
>>
>> dont_want_ids_to_be_returned = ['2','10','5','8']
>>
>> db(db.table.ids_not_in(dont_**want_ids_to_be_returned)).**select()
>>
>> I want the select to return everything except the records with the ids
>> found in dont_want_ids_to_by_returned.
>>
>> --
>> --
>> 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] Re: Query not in

2012-01-20 Thread Anthony
How about:

db(~db.table.id.belongs([2, 10, 5, 8])).select()

Anthony

On Friday, January 20, 2012 4:23:03 PM UTC-5, Detectedstealth wrote:
>
> Hi,
>
> How can I make web2py query for all results that are not in a list of ids?
>
> IE:
>
> dont_want_ids_to_be_returned = ['2','10','5','8']
>
> db(db.table.ids_not_in(dont_want_ids_to_be_returned)).select()
>
> I want the select to return everything except the records with the ids 
> found in dont_want_ids_to_by_returned.
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>  


[web2py] Query not in

2012-01-20 Thread Bruce Wade
Hi,

How can I make web2py query for all results that are not in a list of ids?

IE:

dont_want_ids_to_be_returned = ['2','10','5','8']

db(db.table.ids_not_in(dont_want_ids_to_be_returned)).select()

I want the select to return everything except the records with the ids
found in dont_want_ids_to_by_returned.

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


[web2py] Re: new book now available in HTML (english, japanese, italian)

2012-01-20 Thread peter
The html
Peter

On Jan 20, 2:33 pm, Massimo Di Pierro 
wrote:
> talking about the html or the pdf or the printed one?
>
> On Jan 20, 4:14 am, peter  wrote:
>
>
>
>
>
>
>
> > The book is great, but to my mind there is too big a margin over the
> > left. This is an issue because it is hard to maximise the font size
> > and keep everything on the screen. Could the margin not be reduced to
> > one quarter of its size?
> > Thanks
> > Peter
>
> > On Jan 19, 8:29 am, Stefan Scholl  wrote:
>
> > > Stefan Scholl  wrote:
> > > > Johann Spies  wrote:
> > > >> [-- text/plain, encoding 7bit, charset: ISO-8859-1, 8 lines --]
>
> > > >> It is working for me.  Perhaps you should try again.
>
> > > > Nope, still gone. When I look at the response header I see it's a
> > > > 404 NOT FOUND.
>
> > > >http://web2py.com/book/insteadof
> > > >http://web2py.com/book
>
> > > > See the additional "/", which worked before.
>
> > > I still think this is embarrassing.


Re: [web2py] Re: Problem with .smartgrid on tables with links

2012-01-20 Thread Jim Steil

Massimo

Just did a fresh - hg clone https://code.google.com/p/web2py

...added my app to that installation

and am seeing the same traceback I was getting yesterday.

Traceback(most recent call last):
  File"C:\Deleteme\web2py\gluon\restricted.py",line204,inrestricted
execccodeinenvironment
  File"C:/Deleteme/web2py/applications/infocenter/controllers/administration.py"  
,line1816,in
  File"C:\Deleteme\web2py\gluon\globals.py",line172,in
self._caller=lambdaf:f()
  File"C:\Deleteme\web2py\gluon\tools.py",line2530,inf
returnaction(*a, **b)
  File"C:/Deleteme/web2py/applications/infocenter/controllers/administration.py"  
,line457,inassetTypes
paginate=15,maxtextlength=45)
  File"C:\Deleteme\web2py\gluon\sqlhtml.py",line1967,insmartgrid
user_signature=user_signature,**kwargs)
  File"C:\Deleteme\web2py\gluon\sqlhtml.py",line1815,ingrid
iflink(row):
  File"C:\Deleteme\web2py\gluon\sqlhtml.py",line1964,in
args=request.args[:nargs]+[args0,row.id])))
  File"C:\Deleteme\web2py\gluon\dal.py",line4996,in__getattr__
return self[key]
  File"C:\Deleteme\web2py\gluon\dal.py",line4987,in__getitem__
returndict.__getitem__(self,key)
KeyError:'id'


-Jim

On 1/20/2012 12:19 PM, Massimo Di Pierro wrote:

can you check if trunk fixed it?

On Jan 19, 10:45 am, Jim Steil  wrote:

Hi

Just updated to the latest trunk this morning and now my smartgrids
aren't working where the table being used has links.

Here is what I'm getting:

Traceback(most recent call last):
File"C:\dev\web2py\gluon\restricted.py",line204,inrestricted
  execccodeinenvironment

File"C:/dev/web2py/applications/infocenter/controllers/administration.py",line1816,in
File"C:\dev\web2py\gluon\globals.py",line172,in
  self._caller=lambdaf:f()
File"C:\dev\web2py\gluon\tools.py",line2530,inf
  returnaction(*a, **b)

File"C:/dev/web2py/applications/infocenter/controllers/administration.py",line457,inassetTypes
  paginate=15,maxtextlength=45)
File"C:\dev\web2py\gluon\sqlhtml.py",line1971,insmartgrid
  user_signature=user_signature,**kwargs)
File"C:\dev\web2py\gluon\sqlhtml.py",line1819,ingrid
  iflink(row):
File"C:\dev\web2py\gluon\sqlhtml.py",line1968,in
  args=request.args[:nargs]+[args0,row.id])))
File"C:\dev\web2py\gluon\dal.py",line4996,in__getattr__
  return self[key]
File"C:\dev\web2py\gluon\dal.py",line4987,in__getitem__
  returndict.__getitem__(self,key)
KeyError:'id'

If the table doesn't have any fields referencing other tables, then it
works fine.

Is it just me?

  -Jim


Re: [web2py] Re: Problem with .smartgrid on tables with links

2012-01-20 Thread Jim Steil

Massimo

I think I'm having trouble getting the latest from the trunk.  Here is 
what I'm seeing when I do a pull and then update:



I don't know enough about mercurial to know why this is.

I'm going to do a fresh install from trunk and see what happens.

-Jim

On 1/20/2012 12:19 PM, Massimo Di Pierro wrote:

can you check if trunk fixed it?

On Jan 19, 10:45 am, Jim Steil  wrote:

Hi

Just updated to the latest trunk this morning and now my smartgrids
aren't working where the table being used has links.

Here is what I'm getting:

Traceback(most recent call last):
File"C:\dev\web2py\gluon\restricted.py",line204,inrestricted
  execccodeinenvironment

File"C:/dev/web2py/applications/infocenter/controllers/administration.py",line1816,in
File"C:\dev\web2py\gluon\globals.py",line172,in
  self._caller=lambdaf:f()
File"C:\dev\web2py\gluon\tools.py",line2530,inf
  returnaction(*a, **b)

File"C:/dev/web2py/applications/infocenter/controllers/administration.py",line457,inassetTypes
  paginate=15,maxtextlength=45)
File"C:\dev\web2py\gluon\sqlhtml.py",line1971,insmartgrid
  user_signature=user_signature,**kwargs)
File"C:\dev\web2py\gluon\sqlhtml.py",line1819,ingrid
  iflink(row):
File"C:\dev\web2py\gluon\sqlhtml.py",line1968,in
  args=request.args[:nargs]+[args0,row.id])))
File"C:\dev\web2py\gluon\dal.py",line4996,in__getattr__
  return self[key]
File"C:\dev\web2py\gluon\dal.py",line4987,in__getitem__
  returndict.__getitem__(self,key)
KeyError:'id'

If the table doesn't have any fields referencing other tables, then it
works fine.

Is it just me?

  -Jim
<>

[web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Floyd
I had the same problem. It was related to someggino blocchino the session. It 
never authenticated. Are you cookies enabled?

Bye
Giovanni


[web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Floyd
I had the same problem. It was related to someggino blocchino the session. It 
never authenticated. Are you cookies enabled?

Bye
Giovanni


[web2py] Selectively passing fields for db update

2012-01-20 Thread Yarin
I have a db update method that can update several images- however, at
any given time I will only need to update 1 of the 3 images.

a) Is there a way for me to pass in only the image I want updated
without having to write the update method out 3 times- i.e. can I pass
a pre-defined dictionary of args to the update method? (This may be
more of a Python question than a Web2Py one.)

b) OR- is there a way to pass a default value to the image field if I
don't want it to be overwritten?


db(db.table.id==record_id).update(name=new_name,
image_1
=db.table.image_1.store(request.vars.image_1,'myimage1'),
image_2
=db.table.image_2.store(request.vars.image_2,'myimage2'),
image_3
=db.table.image_3.store(request.vars.image_3,'myimage3'))
)


[web2py] Re: Problem with DB2 and text field type when accessing db2 using ODBC ...

2012-01-20 Thread David Marko
Hi Omi, I have read your blog post already. The reason I have asked is that 
this is existing app, I have switched  from PostgreSQL to DB2 (both db on 
the HW) and app seems to be slower now. I thought it could be the issue 
with ODBC as I expect it generaly slower than native driver.

[web2py] Re: Problem with DB2 and text field type when accessing db2 using ODBC ...

2012-01-20 Thread Omi Chiba
Also, you can refer my blog post.
http://ochiba77.blogspot.com/2011/09/how-to-connect-db2-with-python-pyodbc.html

On Jan 20, 1:47 am, David Marko  wrote:
> Thank you !!! This setting s in db2cli.ini is really working for me without
> any further chnage in web2py tables. Nice.
>
> Also how do you access db2 from web2py? Do you use ODBC or native driver?
> I'm asking because ODBC is working for me just fine, but I also installed
> DB2 python driver and changed the connection string to something like  
> db2://username:password@my_db
> but it doesnt work for me, still getting some strange error that connection
> cannot be provided. Whats your experience here?
>
> David


[web2py] Re: Problem with DB2 and text field type when accessing db2 using ODBC ...

2012-01-20 Thread Paolo Caruccio
I use pyodbc (http://code.google.com/p/pyodbc/) and my connection string is:

db = DAL('db2://DSN=MYDATABASE;UID=userid;PWD=password')

For other details you could read this thread 
https://groups.google.com/d/topic/web2py/HMVE9S2a6sQ/discussion


[web2py] Re: Problem with .smartgrid on tables with links

2012-01-20 Thread Massimo Di Pierro
can you check if trunk fixed it?

On Jan 19, 10:45 am, Jim Steil  wrote:
> Hi
>
> Just updated to the latest trunk this morning and now my smartgrids
> aren't working where the table being used has links.
>
> Here is what I'm getting:
>
> Traceback(most recent call last):
>    File"C:\dev\web2py\gluon\restricted.py",line204,inrestricted
>      execccodeinenvironment
>    File"C:/dev/web2py/applications/infocenter/controllers/administration.py"  
> ,line1816,in
>    File"C:\dev\web2py\gluon\globals.py",line172,in
>      self._caller=lambdaf:f()
>    File"C:\dev\web2py\gluon\tools.py",line2530,inf
>      returnaction(*a, **b)
>    File"C:/dev/web2py/applications/infocenter/controllers/administration.py"  
> ,line457,inassetTypes
>      paginate=15,maxtextlength=45)
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1971,insmartgrid
>      user_signature=user_signature,**kwargs)
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1819,ingrid
>      iflink(row):
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1968,in
>      args=request.args[:nargs]+[args0,row.id])))
>    File"C:\dev\web2py\gluon\dal.py",line4996,in__getattr__
>      return self[key]
>    File"C:\dev\web2py\gluon\dal.py",line4987,in__getitem__
>      returndict.__getitem__(self,key)
> KeyError:'id'
>
> If the table doesn't have any fields referencing other tables, then it
> works fine.
>
> Is it just me?
>
>      -Jim


[web2py] Re: passing navigational links in the header and ajax woes

2012-01-20 Thread Cliff
> Currently, in my application, I am passing navigational links in the
> header, such as /app/controller/view/1/2/3
>
> Where 1/2/3 are things the controller and view use to set the correct
> page.

Why are you doing this?

On Jan 19, 11:53 pm, web-dev-m  wrote:
> Currently, in my application, I am passing navigational links in the
> header, such as /app/controller/view/1/2/3
>
> Where 1/2/3 are things the controller and view use to set the correct
> page.
>
> In my application, I am finding two problems with this.  First is
> security.  Although I have written validation on my controllers (I
> hope), I just worry that with more users some malicious person will
> find a way to get access they shouldn't.
>
> Second and more urgent is my application broke when I tried to write
> my first ajax function, I assume because the navigational variables
> are competing with the ajax variables somehow.  I say this because
> when I make the controller empty and just return a dict everything
> works as normal.  However, when I have the controller look for
> variables in request.vars and I then try to call an ajax function, it
> breaks hideously.
>
> I don't claim to be a great programmer, so it could definitely be a
> convention I am not following.
>
> Has anyone had this problem before?  How did you solve it? Should I
> pass my request.vars into the session and then have the view call
> them?
>
>  I read in the book that I can do ajax trapping and I haven't tried
> that yet, but I didn't think it would be necessary since I could make
> it work without it.  I will try it, but regardless I would love to get
> some feedback.
>
> for clarity, my code causing problems is below:
>
> def my_func():
>     if request.args:
>         #First, I check to see if there is a record, if there is, I
> get some information.
>         check=db(db.mydb.id==request.args(0)).select().first()
>         if check !=None:
>             records=db(db.mydb.id==request.args(0)).select()
>             row = db(db.mydb.id==request.args(0)).select().first()
>             counter=len(records)
>         #if it isnt, I make it with a function
>         else:
>             row = db(db.mydb.id==request.args(0)).select().first()
>             my_id=row.id
>             (filename, stream) =
> db.mydb.myfield.retrieve(row.resourcefield)
>             myfunc(id,filename,stream)
>             records=db(db.mydb.id==request.args(0)).select()
>             counter=len(records)
>         pass
>     #if there is no specific document request, generate a list of
> available files
>     else:
>         redirect(URL('mycontroller','this_function'))
>     return(counter=counter, records=records, row=row)
>
> def myajaxfunc():
>     form=SQLFORM(db.mydb2, _action="myajaxfunc")
>     if form.errors:
>         session.flash="Error: " + str(form.errors)
>     return XML(form)
>
> my view:
>
> {{for i in range(1,5):}}
>     Click me to add a note
>     
> {{pass}}


[web2py] Re: new user startup error question

2012-01-20 Thread Cliff
Sounds like your default browser is not defined.

I'm not a RedHattie, so I can't tell you how to do that.

You can probably start Web2py from the command line, something like:
python web2py.py -a 'your password' -i 127.0.0.1 -p 8000

Look in the ref manual for more info:
http://web2py.com/books/default/chapter/29/4#Command-line-options

On Jan 20, 10:13 am, robert schaefer  wrote:
> Hi,
>
>   I am using RedHat Linux Ver 5.0., python 2.6.2
>   I downloaded the source and started the server with the command "python
> web2py.py" and got the message:
>   Starting browser... Error showing url: There was an error launching
> default action command associated with this location.
>
>   How serious is this error?
>   How do I diagnose it?
>
> thanks,
>  bob s.


[web2py] Re: Global Variables

2012-01-20 Thread Anthony
On Friday, January 20, 2012 11:59:54 AM UTC-5, Noob wrote:
>
> How i create my own's globals variables?


What do you mean? Anything you define in a model will be available in (a) 
all subsequent model files (they are executed alphabetically), (b) the 
controller, and (c) the view. Is that what you're looking for?

Anthony 


[web2py] Global Variables

2012-01-20 Thread Noob
How i create my own's globals variables?


[web2py] Sending simplified email from web2py

2012-01-20 Thread LightDot
Is it possible to send a completely simplified email with web2py 
gluon.tools.Mail class?

I'm using my own SMTP and the procedure itself works fine, I can send 
emails to myself, etc. but the email content produced is giving me 
problems. No matter how plainly are my messages constructed, Mail class 
produces mails with attachments. Testing with only message='plaintext' 
results in a mail with:

Content-Type: multipart/mixed

and

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

cGxhaW50ZXh0 

which is fine for my mail reader, but not for the parser I need to send 
these mails to. I'm trying to send some strictly plain text commands trough 
email, so basically I would like just plain Content-Type: text/plain and 
straight non-encoded text in message body. 

Is this possible with web2py? Should I use smtplib directly instead?


[web2py] Re: error importing custom modules into controller

2012-01-20 Thread monotasker
In case anyone else runs into a similar problem, it turns out that I was 
handling DAL and Crud improperly in the modules I was trying to import. For 
db, I added this in db.py right after the initial definition of db:

current.db = db

Then in my model, in any function that used db, I could just retrieve it 
like this:

db = current.db

With Crud, I could import Crud from gluon.tools at the top of each module 
file. Then in a function (after defining db) I could just define

crud = Crud(db)

With those two changes the imports worked fine. I'm sure all of this was in 
the web2py manual somewhere, but I didn't understand it there. It was 
looking through other questions and answers here on the google group that 
finally clued me in. Thanks to everyone in those discussions (I don't have 
the links, but you know who you are!).


[web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Gerd
In my office i'm also on a proxy (here i get the error), at home it works 
perfectly

regards
Gerd


[web2py] Re: export to csv - no header row

2012-01-20 Thread Adi

Forgive me, I'm still new to python and web2py... 

Any recommended way how to insert/replace the first row with custom headers 
before or after export? 

thanks,
Adi


Re: [web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Candido Vieira da Silva Neto
I'm having the same problem:

Chrome 16.0.912.75 m

Windows XP SP3

Note: I'm connecting through a proxy on work.

On Fri, Jan 20, 2012 at 12:42 PM, Michael Aye wrote:

> The same. Note that what I see in the browser is
> .../demo_admin/ is immediately linked to
> .../demo_admin/default/site
> which then blinks several times back and forth with
> .../demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite
> until the browser gives up.
>
> No luck with the trace of our IT guys?
>



-- 
Candido Vieira da Silva Neto
cvieira...@gmail.com
http://facebook.com/meuestagio
Acesse agora: *http://meuestagio.com* 


[web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Michael Aye
The same. Note that what I see in the browser is
.../demo_admin/ is immediately linked to
.../demo_admin/default/site
which then blinks several times back and forth with
.../demo_admin/default/index?send=%2Fdemo_admin%2Fdefault%2Fsite
until the browser gives up.

No luck with the trace of our IT guys?


[web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Massimo Di Pierro
I still cannot reproduce it. :-(

What if you go directly to:

http://web2py.com/demo_admin/default/site

?

On Jan 20, 8:11 am, Michael Aye  wrote:
> Did empty the cache, no change.
> Steps to reproduce are simple:
> type web2py.com in browser's location bar.
> Click on link for interactive demo: interactive 
> demo
>
> Michael


[web2py] new user startup error question

2012-01-20 Thread robert schaefer
Hi,

  I am using RedHat Linux Ver 5.0., python 2.6.2
  I downloaded the source and started the server with the command "python 
web2py.py" and got the message:
  Starting browser... Error showing url: There was an error launching 
default action command associated with this location.

  How serious is this error?
  How do I diagnose it?

thanks,
 bob s.


[web2py] Re: Need help with drag-n-drop using jQuery

2012-01-20 Thread Frank Hall
The best I can come up with so far is my use of a generic view (I'm just 
getting into this web app stuff). I suspect that I need to elaborate 
index.html. Sound right?
Here's my code:


Control -- dispatch_board.py and default.py

#---
# Name:dispatch_board
# Purpose:
#
# Author:  Frank Hall
#
# Created: 26/12/2011
# Copyright:
# Licence: 
#---
#!/usr/bin/env python

import re
import pickle

def quote(text):
return str(text).replace('\\', '').replace("'", "\\'")

def valid_key(key):
return re.match('L\d+D\d+', key)

def load_key(row, col):
return 'L%sD%s'%(row, col)

def jq_cmd(key, value):
return "jQuery('#%s').val('%s');" % (key, quote(value))

class Node:

def __init__(self, name, value, size=4, url='.', readonly=True):
self.name = name
self.value = value
self.size = size
self.url = url
self.readonly = readonly

def xml(self):
return """
""" % (self.name, self.name, self.value, self.size,
   self.url, self.name, self.url, self.name,
   (self.readonly and 'readonly ') or '')

def __repr__(self):
return self.value


class DispatchBoard:

def dumps(self):
return pickle.dumps(self)

@staticmethod
def loads(data):
return pickle.loads(data)

def load_row_col(self, key):
if key == '':
(row, col) = (-1, -1)
else:
(row, col) = key[1:].split('D')
return (int(row), int(col))

def get_load_value(self, row, col):
key = load_key(row, col)
return self.nodes[key].value

def set_load_value(self, row, col, value):
key = load_key(row, col)
self.nodes[key].value = value
jquery = jq_cmd(key, value)
return jquery

def delete_load(self, row, col):
rnew = self.rows - 1
r = row
jquery = ''
while r < rnew:
value = self.get_load_value(r + 1, col)
jquery += self.set_load_value(r, col, value)
r = r + 1
jquery += self.set_load_value(r, col, '')
return jquery

def insert_load(self, row, col, value, after = False):
rnew = row
if after:
rnew = rnew + 1
r = self.rows - 1
jquery = ''
while r > rnew:
value_move = self.get_load_value(r - 1, col)
jquery += self.set_load_value(r, col, value_move)
r = r - 1
if r == rnew:
jquery += self.set_load_value(r, col, value)
return jquery

def move_load(self, from_row, from_col, to_row, to_col, after = False):
value = self.get_load_value(from_row, from_col)
jquery = self.insert_load(to_row, to_col, value, after)
jquery += self.delete_load(from_row, from_col)
return jquery

def mouseup(self, key):
if (self.drag_key != '') & (key != self.drag_key):
(from_row, from_col) = self.load_row_col(self.drag_key)
(to_row, to_col) = self.load_row_col(key)
jquery = self.move_load(from_row, from_col, to_row, to_col)
else:
jquery = ''
self.drag_key = ''
return jquery

def focus(self, key):
self.drag_key = key

def process(self, callback_args):
##call this in action that creates table, it will handle ajax 
callbacks
func = callback_args['func']
key = callback_args['key']
if func == 'focus':
return self.focus(key)
elif func == 'mouseup':
return self.mouseup(key)

def cell(self, key, value, size=4, readonly=True):
##key is the name of the cell
##value is the initial value of the cell.
if not valid_key(key):
raise SyntaxError, "Invalid cell name: %s" % key
self.nodes[key] = Node(key, value, size, self.url, readonly)

def xml(self):
import gluon.html
(DIV, TABLE, TR, TD, TH, BR) = \
(gluon.html.DIV, gluon.html.TABLE, gluon.html.TR, gluon.html.TD,
 gluon.html.TH, gluon.html.BR)
xml_board = DIV(TABLE( \
TR(TH(),*[TH('Driver %s' % c) \
 for c in range(self.cols)]), \
*[TR(TH('Load %s' % r), \
*[TD(self.nodes[load_key(r, c)]) \
 for c in range(self.cols)]) \
 for r in range(self.rows)])).xml()
return xml_board

def __init__(self, rows, cols, size=4, url='.', readonly=True):
self.rows = rows
self.cols = cols
self.size = size
self.url = url
self.nodes = {}
self.error = 'ERROR: %(error)s'
self.drag_key = ''
for k in xrange(rows*cols):
key = load_key(k/cols, k%cols)
self.cell(key, key

[web2py] Re: my gae+web2py app: feed9 (like reddit)

2012-01-20 Thread Anthony
Very nice. I like the use of jQuery Mobile for mobile devices (works well 
on my Android). Just added to the Poweredby list.

Anthony

On Friday, January 20, 2012 6:38:40 AM UTC-5, sungchi wrote:
>
> source: https://github.com/sungchi/feed9 
> link: http://www.feed9.com/ (korean) 
>
> based reddish source (now RedditClone : 
> https://github.com/mdipierro/web2py-appliances/tree/master/RedditClone 
> ) 
> UI : http://twitter.github.com/bootstrap/ 
>
> Well .. Just think like Reddit 
> Thank you 
>


[web2py] Re: my gae+web2py app: feed9 (like reddit)

2012-01-20 Thread Massimo Di Pierro
:-)

On Jan 20, 5:38 am, sungchi  wrote:
> source:https://github.com/sungchi/feed9
> link:http://www.feed9.com/(korean)
>
> based reddish source (now RedditClone 
> :https://github.com/mdipierro/web2py-appliances/tree/master/RedditClone
> )
> UI :http://twitter.github.com/bootstrap/
>
> Well .. Just think like Reddit
> Thank you


[web2py] Re: new book now available in HTML (english, japanese, italian)

2012-01-20 Thread Massimo Di Pierro
talking about the html or the pdf or the printed one?

On Jan 20, 4:14 am, peter  wrote:
> The book is great, but to my mind there is too big a margin over the
> left. This is an issue because it is hard to maximise the font size
> and keep everything on the screen. Could the margin not be reduced to
> one quarter of its size?
> Thanks
> Peter
>
> On Jan 19, 8:29 am, Stefan Scholl  wrote:
>
>
>
>
>
>
>
> > Stefan Scholl  wrote:
> > > Johann Spies  wrote:
> > >> [-- text/plain, encoding 7bit, charset: ISO-8859-1, 8 lines --]
>
> > >> It is working for me.  Perhaps you should try again.
>
> > > Nope, still gone. When I look at the response header I see it's a
> > > 404 NOT FOUND.
>
> > >http://web2py.com/book/insteadof
> > >http://web2py.com/book
>
> > > See the additional "/", which worked before.
>
> > I still think this is embarrassing.


[web2py] Re: Too many redirects when trying to use interactive demo

2012-01-20 Thread Michael Aye
Did empty the cache, no change.
Steps to reproduce are simple:
type web2py.com in browser's location bar.
Click on link for interactive demo: interactive 
demo

Michael


[web2py] Re: Web2py auth and Qooxdoo

2012-01-20 Thread Phyo Arkar
To keep it simple.

How can i login (without using form) to web2py Auth  via AJAX?

Thanks

Phyo.

On Fri, Jan 20, 2012 at 7:45 PM, Phyo Arkar wrote:

> hello web2py.
>
> I am trying to get auth working with qooxdoo , can i know how should i
> login using ajax and (ofcoz use session) of webpy?
>
> Thanks
>
> Phyo.
>


[web2py] Re: Book-bug

2012-01-20 Thread Johann Spies
Apologies.  I was wrong.  I did a db.table.truncate in stead of
db.table.truncate()

The book is correct.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Book-bug

2012-01-20 Thread Johann Spies
The statement in the book "*You can truncate the table, i.e., delete all
records and reset the counter of the id*."  is not correct.  The id-counter
does not get reset during truncate.  That is the case with Postgresql. I
have not tested that on other databases.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Web2py auth and Qooxdoo

2012-01-20 Thread Phyo Arkar
hello web2py.

I am trying to get auth working with qooxdoo , can i know how should i
login using ajax and (ofcoz use session) of webpy?

Thanks

Phyo.


[web2py] uuid-references and ondelete

2012-01-20 Thread Johann Spies
I suppose that when the book refers to references it always means a
reference to the other record's id.  How do I implement ondelete when using
uuid references as foreign keys and not the id?

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: Rackspace install.

2012-01-20 Thread Simon Ashley
Thanks, the job has been let and is under way ...

On Jan 20, 8:42 pm, Simon Ashley  wrote:
> Have totally run out of time, and have posted on expect4solutions a
> job for someone to complete an install/ fresh install on rackspace.
> Postgres / apache (or equivalent).
> Need a turnaround in the next 36 hours as required for Monday.
> Contact me privately.
>
> TIA,


[web2py] my gae+web2py app: feed9 (like reddit)

2012-01-20 Thread sungchi
source: https://github.com/sungchi/feed9
link: http://www.feed9.com/ (korean)

based reddish source (now RedditClone :
https://github.com/mdipierro/web2py-appliances/tree/master/RedditClone
)
UI : http://twitter.github.com/bootstrap/

Well .. Just think like Reddit
Thank you


[web2py] Re: sqlhtml unicode error

2012-01-20 Thread Alan Etkin
The book states (2.4.1) "... By design, web2py uses UTF8 encoded
strings internally. ..."

So I guess that the text returned by the server should be encoded to
UTF-8 in order to avoid string handling errors when rendering for
browser output.

On 19 ene, 14:44, Alan Etkin  wrote:
> The text encoding is read from an email.message.Message created when
> the mail is fetched from the server and before sending the data to the
> base adapter parse function (by the way, I sent new versions of the
> adapter these days to the issue page after it was marked as fixed)
>
> In IMAPAdapter I am passing the complete message RFC822 payload to 
> aunicodeinstance with the charset declared in the message's envelope
> (or using "utf-8" as default), and this way theunicodeerrordoesn't
> reproduce (without need to change thesqlhtml.py module).
>
> I did not edit the layout encoding, I am just using the scaffolding
> app to test the email queries. The message rows passed to sqltables
> might contain html, is it possible that these parts are 
> producingunicodeerrors?
>
> On 19 ene, 12:55, Massimo Di Pierro 
> wrote:
>
> > Is the page html header declaring the utf8 encoding or are using in a
> > layout that uses a different encoding?
>
> > On Jan 19, 7:21 am, Alan Etkin  wrote:
>
> > > I found that theUnicodeerrors are originated because of incompatible
> > > encodings when web2py tries to read the raw message and render the
> > > data for browser output. I solved it encoding the RFC822 raw text
> > > before parsing the response data as Rows. Still i am not sure if this
> > > is the correct way for processing the response text so it can be sent
> > > safely (without misread characters) to the user interface. Anyway, it
> > > seems to work well, without instensive testing.
>
> > > On 18 ene, 18:40, Alan Etkin  wrote:
>
> > > > I am trying to generate sqltables with the experimental IMAPAdapter
> > > > select output, but with some rows, an exception is raised at the
> > > >sqlhtmlmodule. It has to do withunicodeand charsets whensqlhtml
> > > > processes the rows object returned by the adapter's select method, but
> > > > I cannot find a proper way of solving it. Here is theerrortrace:
>
> > > > Traceback (most recent call last):
> > > >   File "/home/alan/web2py-hg/gluon/restricted.py", line 204, in
> > > > restricted
> > > >     exec ccode in environment
> > > >   File "/home/alan/web2py-hg/applications/queries/views/default/
> > > > index.html", line 126, in 
> > > >   File "/home/alan/web2py-hg/gluon/globals.py", line 181, in write
> > > >     self.body.write(xmlescape(data))
> > > >   File "/home/alan/web2py-hg/gluon/html.py", line 114, in xmlescape
> > > >     return data.xml()
> > > >   File "/home/alan/web2py-hg/gluon/dal.py", line 7442, in xml
> > > >     returnsqlhtml.SQLTABLE(self).xml()
> > > >   File "/home/alan/web2py-hg/gluon/sqlhtml.py", line 2197, in __init__
> > > >     ur =unicode(r, 'utf8')
> > > >   File "/usr/lib/python2.6/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
> > > > 1227-1229: invalid data
>
> > > > I found a workaround to avoid the exception but I doubt it's the
> > > > correct fix, because it just prevents web2py to create theunicode
> > > > object and use the raw input instead.
>
> > > > This is the workaround: (gluon/sqlhtml.py Line 2196)
>
> > > >                     try:
> > > >                         ur =unicode(r, 'utf-8')
> > > >                     except UnicodeDecodeError, e:
> > > >                         ur = r
>
> > > > Replacing this line:
> > > >                     ur =unicode(r, 'utf8')
>
> > > > When creating the Row objects at the adapter, I have to handle
> > > > different encodings depending on the message. What would be an
> > > > appropiate way of encoding data before creating the Row objects, so
> > > >unicodeerrors can be avoided?
>
> > > > This is the adapter method i am using to store the parse input for
> > > > each text field
>
> > > >     def encode_text(self, text, charset, errors="replace"):
> > > >         """ convert text for mail tounicode"""
> > > >         if text is None:
> > > >             text = ""
> > > >         else:
> > > >             if charset is not None:
> > > >                 text =unicode(text, charset, errors)
> > > >             else:
> > > >                 text =unicode(text, "utf-8", errors)
> > > >         return text
>
> > > > Thanks
>
> > > > I am using the last source hg version (1.99.4) with Python 2.6.5 on a
> > > > Mandriva GNU/Linux machine.
>
>


[web2py] Re: HOWTO: getting web2py to run on Android mobile devices

2012-01-20 Thread fpp
More on Jota :

* Website : http://sites.google.com/site/aquamarinepandora/home/jota-text-editor

* the author explains how to create and contribute syntax files, maybe
someone can look into that ?

* the (very customizable) toolbar, although it takes up some screen
space, is a life-saver on devices without keyboards...


[web2py] Re: HOWTO: getting web2py to run on Android mobile devices

2012-01-20 Thread fpp


Thanks, Vinicius.

Here is another tip for those who are going to use SL4A to edit files
directly on their device :

... do yourself a favour and install the "Jota text editor" from the
Market, right now...

It's not only free, but also ad-free and even open-source... and very
well done !

Unfortunately it does not (yet) have syntax highlighting for Python,
but otherwise it is a pleasure to use and is miles above the default
editor.

Its specific cut-n-paste system, in particular, is *way* better than
the brain-dead Android standard (which I still fail to grok, and hate
with a passion :-)

fp


[web2py] Rackspace install.

2012-01-20 Thread Simon Ashley
Have totally run out of time, and have posted on expect4solutions a
job for someone to complete an install/ fresh install on rackspace.
Postgres / apache (or equivalent).
Need a turnaround in the next 36 hours as required for Monday.
Contact me privately.

TIA,


[web2py] Re: new book now available in HTML (english, japanese, italian)

2012-01-20 Thread peter
The book is great, but to my mind there is too big a margin over the
left. This is an issue because it is hard to maximise the font size
and keep everything on the screen. Could the margin not be reduced to
one quarter of its size?
Thanks
Peter

On Jan 19, 8:29 am, Stefan Scholl  wrote:
> Stefan Scholl  wrote:
> > Johann Spies  wrote:
> >> [-- text/plain, encoding 7bit, charset: ISO-8859-1, 8 lines --]
>
> >> It is working for me.  Perhaps you should try again.
>
> > Nope, still gone. When I look at the response header I see it's a
> > 404 NOT FOUND.
>
> >http://web2py.com/book/instead of
> >http://web2py.com/book
>
> > See the additional "/", which worked before.
>
> I still think this is embarrassing.