[web2py] Re: Background process scheduler and GAE

2012-02-02 Thread Douglas Ross
Thanks very much, I will have a look.

Doug

On Feb 2, 10:22 am, howesc  wrote:
> use the GAE taskqueues for background processes.  i also recommend looking
> at GAE backend instances for background tasks.


Re: [web2py] Any bored developers want to help?

2012-02-02 Thread Sebastian E. Ovide
did you use web2py for ethicaldeal.com and youadworld.com  ?

On Thu, Feb 2, 2012 at 3:32 AM, Bruce Wade  wrote:

> Hi,
>
> I am currently using web2py to build a fitness portal, that allows members
> to:
>
>1. track their food consumption
>2. calculate the calories/fat/protein etc..,
>3. build and track their workout programs
>4. track fitness progress IE: Weight changes, muscle gained etc...
>5. trainers can track their clients, find new clients
>6. companies can track their trainers, find new trainers, and track
>their clients or find new clients.
>
>
> Currently their are 2 designers and 2 developers on the team (including
> myself).
>
> This is a challenging project and I am willing to payout a good % to any
> developers who become core developers of the application.
>
> A little about me:
> I have developed the very successful ethicaldeal.com group-on clone
> website. (Making over $800 a day in revenue)
> Developed the so far very successful youadworld.com advertising website.
> (Very successful means, it launched November 18th, 2011 and has already
> generated over $5 million in revenue)
>
> Unfortunately I am not the owner of either of these two projects, so I
> don't get to benefit all that much from their success even though I spent
> lots of sleepless nights on the development :(. However I have learned a
> lot from working on these and other projects and want to now make one I own
> that is very successful.
>
> Anyway enough of the rant if anyone is interested in potentially wasting a
> lot of their time to help build something that will benefit a lot of people
> let me know.
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>



-- 
Sebastian E. Ovide


Re: [web2py] Webfaction account with multiple apps under 1 web2py install

2012-02-02 Thread Vasile Ermicioi
I will show what I use

in routes.py I have:

routes_in = (
#('/admin/(.*)', '/admin/$1'),
('(.*):https?://(www\.)?site1\.com:(.*)/', '/site1/'),
('(.*):https?://(www\.)?site2\.com:(.*)/', '/site2/'),
)

after you change routes.py you need to restart your server (apache, or
whatever you use)
if you use uwsgi and started it with touch-reload option you only need to
touch the file that you passed
touch tmp/uwsgireload.txt

if you need more
http://web2py.com/books/default/chapter/29/4#URL-rewrite


Re: [web2py] Webfaction account with multiple apps under 1 web2py install

2012-02-02 Thread Martín Mulone
Read: http://web2py.com/books/default/chapter/29/4#URL-rewrite

Take a look to the router.py in web2py root folder, to use it you have to
rename it to routes.py

1.
2.
3.
4.
5.
6.
7.
8.

routers = dict(
  BASE  = dict(
  domains = {
  'domain1.com' : 'app1',
  'domain2.com' : 'app2',
  }
  ),
)




2012/2/1 Jim Steil 

> Hi
>
> I've got a couple different apps I want to deploy under my web2py instance
> on webfaction.  Unfortunately, I'm well versed in routing and knowing how
> to route different requests to different apps.
>
> I have different urls that I'd like mapped to different apps.
>
> www.application1.com I would like to point to web2py/applications/**
> application1
> www.application2.com I would like to point to web2py/applications/**
> application2
>
> And, if possible, I prefer to not show the application name in the url ->
> www.application1.com/**application1/controller/**function
>
> Controller and function are fine but would prefer to eliminate the
> duplicate application1.  If there is a spot in the manual I should study
> harder, please reference it.  Unfortunately, I'm relatively weak when it
> comes to url rewriting/routing and regular expressions.
>
>-Jim
>
>


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


Re: [web2py] Any bored developers want to help?

2012-02-02 Thread Bruce Wade
No, used cakephp for ethicaldeal, and used pyramid for youadworld, however
for the last month I have been porting youadworld.com to web2py and the new
version is much much much better then the current live one. I will update
the development version of the site later today and provide a link to see
the new youadworld.com (not complete yet, but getting close)

On Thu, Feb 2, 2012 at 1:19 AM, Sebastian E. Ovide <
sebastian.ov...@gmail.com> wrote:

> did you use web2py for ethicaldeal.com and youadworld.com  ?
>
>
> On Thu, Feb 2, 2012 at 3:32 AM, Bruce Wade  wrote:
>
>> Hi,
>>
>> I am currently using web2py to build a fitness portal, that allows
>> members to:
>>
>>1. track their food consumption
>>2. calculate the calories/fat/protein etc..,
>>3. build and track their workout programs
>>4. track fitness progress IE: Weight changes, muscle gained etc...
>>5. trainers can track their clients, find new clients
>>6. companies can track their trainers, find new trainers, and track
>>their clients or find new clients.
>>
>>
>> Currently their are 2 designers and 2 developers on the team (including
>> myself).
>>
>> This is a challenging project and I am willing to payout a good % to any
>> developers who become core developers of the application.
>>
>> A little about me:
>> I have developed the very successful ethicaldeal.com group-on clone
>> website. (Making over $800 a day in revenue)
>> Developed the so far very successful youadworld.com advertising website.
>> (Very successful means, it launched November 18th, 2011 and has already
>> generated over $5 million in revenue)
>>
>> Unfortunately I am not the owner of either of these two projects, so I
>> don't get to benefit all that much from their success even though I spent
>> lots of sleepless nights on the development :(. However I have learned a
>> lot from working on these and other projects and want to now make one I own
>> that is very successful.
>>
>> Anyway enough of the rant if anyone is interested in potentially wasting
>> a lot of their time to help build something that will benefit a lot of
>> people let me know.
>>
>> --
>> --
>> Regards,
>> Bruce Wade
>> http://ca.linkedin.com/in/brucelwade
>> http://www.wadecybertech.com
>> http://www.warplydesigned.com
>> http://www.fitnessfriendsfinder.com
>>
>
>
>
> --
> Sebastian E. Ovide
>
>
>
>


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


Re: [web2py] Webfaction account with multiple apps under 1 web2py install

2012-02-02 Thread Jim Steil

Wow,  beautiful and simple.

Thanks Martin, I really appreciate it.

-Jim

On 2/2/2012 4:26 AM, Martín Mulone wrote:

Read: http://web2py.com/books/default/chapter/29/4#URL-rewrite

Take a look to the router.py in web2py root folder, to use it you have 
to rename it to routes.py


1.
2.
3.
4.
5.
6.
7.
8.

routers=dict(

   BASE=dict(

   domains= {

   'domain1.com  ':'app1',

   'domain2.com  ':'app2',

   }
   ),
)




2012/2/1 Jim Steil mailto:j...@qlf.com>>

Hi

I've got a couple different apps I want to deploy under my web2py
instance on webfaction.  Unfortunately, I'm well versed in routing
and knowing how to route different requests to different apps.

I have different urls that I'd like mapped to different apps.

www.application1.com  I would like to
point to web2py/applications/application1
www.application2.com  I would like to
point to web2py/applications/application2

And, if possible, I prefer to not show the application name in the
url -> www.application1.com/application1/controller/function


Controller and function are fine but would prefer to eliminate the
duplicate application1.  If there is a spot in the manual I should
study harder, please reference it.  Unfortunately, I'm relatively
weak when it comes to url rewriting/routing and regular expressions.

   -Jim




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



Re: [web2py] Webfaction account with multiple apps under 1 web2py install

2012-02-02 Thread Jim Steil
Vasile - Thanks for the reply - However, with my aversion to regular 
expressions, I chose to use the solution that Martin provided.


Thanks again.

-Jim

On 2/2/2012 3:22 AM, Vasile Ermicioi wrote:

I will show what I use

in routes.py I have:

routes_in = (
#('/admin/(.*)', '/admin/$1'),
('(.*):https?://(www\.)?site1\.com:(.*)/', '/site1/'),
('(.*):https?://(www\.)?site2\.com:(.*)/', '/site2/'),
)

after you change routes.py you need to restart your server (apache, or 
whatever you use)
if you use uwsgi and started it with touch-reload option you only need 
to touch the file that you passed

touch tmp/uwsgireload.txt

if you need more
http://web2py.com/books/default/chapter/29/4#URL-rewrite


[web2py] Re: bootstrap 2

2012-02-02 Thread GoldenTiger
I have been following Addy Osmani for years, he has a lot of greats js
projects, do not lose track of him, sure he will be usefull many more
times


On 1 feb, 19:31, Martín Mulone  wrote:
> tell me if you need help
>
> 2012/2/1 Bruno Rocha 
>
>
>
>
>
>
>
>
>
> > I am working to port web2py grid layout to use it.
>
> > and a I have a new feature to grid (sub grids/details forms) experimental
>
> > I hope to contribute with it very soon
>
> > On Wed, Feb 1, 2012 at 4:18 PM, Martín Mulone 
> > wrote:
>
> >> jquery ui bootstrap is very nice!
>
> >> 2012/2/1 Bruno Rocha 
>
> >>> Bootstrap 2 released, full responsible layout!
>
> >>> I am working on porting scaffold app to bootstrap with jquery ui support!
>
> >>>http://twitter.github.com/bootstrap/download.html
>
> >>>http://addyosmani.github.com/jquery-ui-bootstrap/
>
> >>> --
>
> >>> Bruno Rocha
> >>> [http://rochacbruno.com.br]
>
> >> --
> >>  http://www.tecnodoc.com.ar
>
> > --
>
> > Bruno Rocha
> > [http://rochacbruno.com.br]
>
> --
>  http://www.tecnodoc.com.ar


[web2py] Re: bootstrap 2

2012-02-02 Thread GoldenTiger
I have been following Addy Osmani for years, he has a lot of greats
js projects, do not lose track of him, sure he will be usefull many
more times
check this http://vimeo.com/35924671

On 2 feb, 15:53, GoldenTiger  wrote:
> I have been following Addy Osmani for years, he has a lot of greats js
> projects, do not lose track of him, sure he will be usefull many more
> times
>
> On 1 feb, 19:31, Martín Mulone  wrote:
>
>
>
>
>
>
>
> > tell me if you need help
>
> > 2012/2/1 Bruno Rocha 
>
> > > I am working to port web2py grid layout to use it.
>
> > > and a I have a new feature to grid (sub grids/details forms) experimental
>
> > > I hope to contribute with it very soon
>
> > > On Wed, Feb 1, 2012 at 4:18 PM, Martín Mulone 
> > > wrote:
>
> > >> jquery ui bootstrap is very nice!
>
> > >> 2012/2/1 Bruno Rocha 
>
> > >>> Bootstrap 2 released, full responsible layout!
>
> > >>> I am working on porting scaffold app to bootstrap with jquery ui 
> > >>> support!
>
> > >>>http://twitter.github.com/bootstrap/download.html
>
> > >>>http://addyosmani.github.com/jquery-ui-bootstrap/
>
> > >>> --
>
> > >>> Bruno Rocha
> > >>> [http://rochacbruno.com.br]
>
> > >> --
> > >>  http://www.tecnodoc.com.ar
>
> > > --
>
> > > Bruno Rocha
> > > [http://rochacbruno.com.br]
>
> > --
> >  http://www.tecnodoc.com.ar


[web2py] Only 2 Weeks Left! -- Web2py Application Exhibition Version 3.0

2012-02-02 Thread NetAdmin
There are 2 weeks left for submissions for the  Web2py Application
Exhibition Version 3.0

For more information, see the "pinned" message at the top of this
group.

(   http://groups.google.com/group/web2py/t/466b21110dbd2d32 )

Good Luck!

mr.netad...@gmail.com


[web2py] Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Cliff
I plan to port a suite of applications from PHP to Web2py.

Even though it's a group of applications, I'm thinking the best
solution is to lump them all into one app.  I have used the
"cooperating applications" design described in the manual and I want
to do something else this time.

The only problem I can see is the performance hit from running the
models on every request.  Bruno Rocha's no-model design may solve that
problem, though.

Has anyone experienced other problems with putting everything in one
app?

Does anyone have an opinion on a different design approach?

I really want to make a considered decision here, because it is one
not easily reversed once the apps are in production.

Thanks,
Cliff Kachinske


[web2py] Re: Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Ross Peoples
I have used the plugin approach before with success on a medium-sized app. 
You just have to design them properly or the plugins will rely on each 
other, which kind of defeats the purpose.

[web2py] Re: Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Cliff
Ross,

Thanks for the idea.  I haven't really thought about plugins.

The plugins would share some data, mostly the auth tables, but some
others as well.

Is that what you mean by "rely on each other?"

Thank you,
Cliff Kachinske

On Feb 2, 10:48 am, Ross Peoples  wrote:
> I have used the plugin approach before with success on a medium-sized app.
> You just have to design them properly or the plugins will rely on each
> other, which kind of defeats the purpose.


[web2py] Re: Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Ross Peoples
If they are only sharing the auth table, then it's not a big deal, since 
the auth tables are there by default. But plugins are meant to be 
completely isolated from each other, completely unaware that other plugins 
exist.

Putting core logic (accessing data) into modules and using more generic 
plugins to handle the views might be the best way to go. I use modules 
extensively, and only use models to set up the module instances as global 
variables. I use the singleton pattern for my modules, which works well for 
me, but Bruno's approach is also pretty good, but a little more complicated.


Re: [web2py] Webfaction account with multiple apps under 1 web2py install

2012-02-02 Thread Vasile Ermicioi
>
> Vasile - Thanks for the reply - However, with my aversion to regular
> expressions, I chose to use the solution that Martin provided.


no problem :)


[web2py] Re: Anybody want to join me

2012-02-02 Thread howesc
i don't have much time to be a constant help, but feel free to post 
questions about web2py/GAE.  i've got apps big and small running, and have 
made a crap-ton of mistakes so i try my best to answer those questions as 
they come up!


[web2py] Re: Opinions, please: best way to set up multiple apps on one site?

2012-02-02 Thread Cliff
I saw your post on that.

I have the thread bookmarked.

On Feb 2, 11:05 am, Ross Peoples  wrote:
> If they are only sharing the auth table, then it's not a big deal, since
> the auth tables are there by default. But plugins are meant to be
> completely isolated from each other, completely unaware that other plugins
> exist.
>
> Putting core logic (accessing data) into modules and using more generic
> plugins to handle the views might be the best way to go. I use modules
> extensively, and only use models to set up the module instances as global
> variables. I use the singleton pattern for my modules, which works well for
> me, but Bruno's approach is also pretty good, but a little more complicated.


[web2py] Re: using radio widget can't receive the empty submit

2012-02-02 Thread DenesL
Your view does not include the default layout which in turn includes
the response.flash, so you have to put it in your view somewhere:

{{=response.flash}}


On Feb 1, 9:11 pm, Dan  wrote:
> Hi Denesl,
> Thanks for the hints. I got the sumbit info from the xform.
>      '_formname': 'xform'}>
> But what I want is the flash response "Form X Response" shows up like
> the dropdown select form behaviors and other form.vars during the
> submit.
>
> In "form", it's okay but not in "xform".  Many thanks


[web2py] Deploying on windows - login works locally but not remotely

2012-02-02 Thread Jim Steil

Hi

I have an app that I'm deploying on a different windows box on our 
internal network.  I can connect to the app from a browser on that 
server without any problems.  I can login with no problems and do what I 
want.


When I go to a remote machine to connect to it, I can connect just fine 
and navigate around until I hit a page that requires me to login.  
Instead of getting the login page, I get:



 invalid view (default/user.html)

Works fine if I'm browsing from the local machine, but fails on any 
remote machine.


Thoughts?

-Jim



[web2py] Re: WHERE equivalent in query?

2012-02-02 Thread shartha
Thanks. =)

On Feb 2, 12:33 am, Johann Spies  wrote:
> On 2 February 2012 07:40, shartha  wrote:
>
>
>
>
>
>
>
>
>
> > I have two databases as follows:
>
> > db.define_table('city',
> >    Field('name'),
> >    Field('state'),
> >    format = '%(name)s'
> > )
>
> > db.define_table('users',
> >   Field('name'),
> >   Field('city',db.city),
> >   Field('phone'),
> >   Field('email')
> > )
>
> > What query will list all the users that are from a particular city,
> > e.g. with id = 1?
>
> Say 'Cape Town' is in 'city' then the following query would provide all the
> users linked to that city:
>
> list_of_users_in_cape_town = db((db.city.name == 'Cape
> Town')&(db.users.city == db.city.id)).select()
>
> Regards
> Johnann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)


[web2py] Re: Deploying on windows - login works locally but not remotely

2012-02-02 Thread Anthony
Do you have an actual /views/default/user.html view, or are you relying on 
generic.html to show the login form? If the latter, not that by default, 
the 'welcome' app only enables generic views for local requests.

Anthony

On Thursday, February 2, 2012 1:04:43 PM UTC-5, Jim S wrote:
>
>  Hi
>
> I have an app that I'm deploying on a different windows box on our 
> internal network.  I can connect to the app from a browser on that server 
> without any problems.  I can login with no problems and do what I want. 
>
> When I go to a remote machine to connect to it, I can connect just fine 
> and navigate around until I hit a page that requires me to login.  Instead 
> of getting the login page, I get:
>
> invalid view (default/user.html) Works fine if I'm browsing from the 
> local machine, but fails on any remote machine.
>
> Thoughts?
>
> -Jim
>
>  

[web2py] How to replace this native query with DAL

2012-02-02 Thread Bruce Wade
Need a little assistance in this last query condition syntax.
now = datetime.now()
h = 72
seconds = h*3600
if not self.reg_time or (now-self.reg_time).total_seconds() <
seconds and self.enabled==True:
sqlstr = """ select sum(happen_amount) from cash_journal
 where transaction_type in ('s','l','p')
   and extract(epoch from
(:now-happen_time))<:seconds
   and distributor_id = :id
   lockAmount = engine.execute(text(sqlstr), now=now,
seconds=seconds, id=self.id).scalar()

So for I have everything converted except "and extract(epoch from
(:now-happen_time))<:seconds"

now = datetime.datetime.now()
h = 72 # Need to pull this from database
seconds = h * 3600
payback_types = ['s','p']
if not distributor.reg_time or (now -
distributor.reg_time).total_seconds() < seconds and distributor.enabled ==
True:
payback_types.append('l')

happen_sum = self.db.cash_journal.happen_amount.sum()
rows = self.db((self.db.cash_journal.distributor_id ==
distributor.id) & \

 
(self.db.cash_journal.transaction_type.belongs(payback_types))).select(self.db.cash_journal.happen_amount.sum())

How would I do add this condition to the above rows query: "and
extract(epoch from (:now-happen_time))<:seconds"
-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Deploying on windows - login works locally but not remotely

2012-02-02 Thread Jim Steil

You are good!

Is this done because of a security concern?  Would 'best practice' 
dictate that I not use the generic views.


-Jim

On 2/2/2012 12:14 PM, Anthony wrote:
Do you have an actual /views/default/user.html view, or are you 
relying on generic.html to show the login form? If the latter, not 
that by default, the 'welcome' app only enables generic views for 
local requests.


Anthony

On Thursday, February 2, 2012 1:04:43 PM UTC-5, Jim S wrote:

Hi

I have an app that I'm deploying on a different windows box on our
internal network.  I can connect to the app from a browser on that
server without any problems.  I can login with no problems and do
what I want.

When I go to a remote machine to connect to it, I can connect just
fine and navigate around until I hit a page that requires me to
login.  Instead of getting the login page, I get:


  invalid view (default/user.html)

Works fine if I'm browsing from the local machine, but fails on
any remote machine.

Thoughts?

-Jim



Re: [web2py] Re: Deploying on windows - login works locally but not remotely

2012-02-02 Thread Carlos Costa
I think their purpose is for prototyping.

2012/2/2 Jim Steil :
> You are good!
>
> Is this done because of a security concern?  Would 'best practice' dictate
> that I not use the generic views.
>
>     -Jim
>
>
> On 2/2/2012 12:14 PM, Anthony wrote:
>
> Do you have an actual /views/default/user.html view, or are you relying on
> generic.html to show the login form? If the latter, not that by default, the
> 'welcome' app only enables generic views for local requests.
>
> Anthony
>
> On Thursday, February 2, 2012 1:04:43 PM UTC-5, Jim S wrote:
>>
>> Hi
>>
>> I have an app that I'm deploying on a different windows box on our
>> internal network.  I can connect to the app from a browser on that server
>> without any problems.  I can login with no problems and do what I want.
>>
>> When I go to a remote machine to connect to it, I can connect just fine
>> and navigate around until I hit a page that requires me to login.  Instead
>> of getting the login page, I get:
>>
>> invalid view (default/user.html)
>>
>> Works fine if I'm browsing from the local machine, but fails on any remote
>> machine.
>>
>> Thoughts?
>>
>>     -Jim
>>
>



-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


[web2py] Error writing an auth_event

2012-02-02 Thread pbreit
My code is erroring and it looks like the culprit is the logging of an 
auth_event. It's happening on a lightly customized auth_user Profile update.



Traceback (most recent call last):
  File "/opt/web2py/gluon/restricted.py", line 204, in restricted
exec ccode in environment
  File "/opt/web2py/applications/init/controllers/default.py" 
, line 133, in 

  File "/opt/web2py/gluon/globals.py", line 172, in 
self._caller = lambda f: f()
  File "/opt/web2py/applications/init/controllers/default.py" 
, line 85, in user
form = auth()
  File "/opt/web2py/gluon/tools.py", line 1159, in __call__
return getattr(self,args[0])()
  File "/opt/web2py/gluon/tools.py", line 2431, in profile
onvalidation=onvalidation, hideerror=self.settings.hideerror):
  File "/opt/web2py/gluon/sqlhtml.py", line 1088, in accepts
hideerror=hideerror,
  File "/opt/web2py/gluon/html.py", line 1807, in accepts
status = self._traverse(status,hideerror)
  File "/opt/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/opt/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/opt/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/opt/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
  File "/opt/web2py/gluon/html.py", line 756, in _traverse
newstatus = self._validate()
  File "/opt/web2py/gluon/html.py", line 1572, in _validate
(value, errors) = validator(value)
  File "/opt/web2py/gluon/validators.py", line 549, in __call__
elif str(rows[0]._id) != str(self.record_id):
  File "/opt/web2py/gluon/dal.py", line 5459, in __getattr__
return self[key]
  File "/opt/web2py/gluon/dal.py", line 5450, in __getitem__
return dict.__getitem__(self, key)
KeyError: '_id'



Function argument list

(self=}>, key='_id')
Code listing

5445.
5446.
5447.
5448.
5449.
5450.

5451.
5452.
5453.
5454.

elif m:
try:
return dict.__getitem__(self, m.group(1))[m.group(2)]
except (KeyError,TypeError):
key = m.group(2)
return dict.__getitem__(self, key)


def __call__(self,key):
return self.__getitem__(key)

Variablesself}>dict.__getitem__builtindictkey'_id'


Re: [web2py] Error writing an auth_event

2012-02-02 Thread Carlos Costa
Hard to guess withou the model, but looks like its related to the
membership.

2012/2/2 pbreit 

> My code is erroring and it looks like the culprit is the logging of an
> auth_event. It's happening on a lightly customized auth_user Profile update.
>
>
>
> Traceback (most recent call last):
>   File "/opt/web2py/gluon/restricted.py", line 204, in restricted
> exec ccode in environment
>   File "/opt/web2py/applications/init/controllers/default.py" 
> , line 133, in 
> 
>   File "/opt/web2py/gluon/globals.py", line 172, in 
> self._caller = lambda f: f()
>   File "/opt/web2py/applications/init/controllers/default.py" 
> , line 85, in 
> user
> form = auth()
>   File "/opt/web2py/gluon/tools.py", line 1159, in __call__
> return getattr(self,args[0])()
>   File "/opt/web2py/gluon/tools.py", line 2431, in profile
> onvalidation=onvalidation, hideerror=self.settings.hideerror):
>   File "/opt/web2py/gluon/sqlhtml.py", line 1088, in accepts
> hideerror=hideerror,
>   File "/opt/web2py/gluon/html.py", line 1807, in accepts
> status = self._traverse(status,hideerror)
>   File "/opt/web2py/gluon/html.py", line 749, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/opt/web2py/gluon/html.py", line 749, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/opt/web2py/gluon/html.py", line 749, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/opt/web2py/gluon/html.py", line 749, in _traverse
> newstatus = c._traverse(status,hideerror) and newstatus
>   File "/opt/web2py/gluon/html.py", line 756, in _traverse
> newstatus = self._validate()
>   File "/opt/web2py/gluon/html.py", line 1572, in _validate
> (value, errors) = validator(value)
>   File "/opt/web2py/gluon/validators.py", line 549, in __call__
> elif str(rows[0]._id) != str(self.record_id):
>   File "/opt/web2py/gluon/dal.py", line 5459, in __getattr__
> return self[key]
>   File "/opt/web2py/gluon/dal.py", line 5450, in __getitem__
> return dict.__getitem__(self, key)
> KeyError: '_id'
>
>
>
> Function argument list
>
> (self= }>, key='_id')
> Code listing
>
> 5445.
> 5446.
> 5447.
> 5448.
> 5449.
> 5450.
>
> 5451.
> 5452.
> 5453.
> 5454.
>
> elif m:
> try:
> return dict.__getitem__(self, m.group(1))[m.group(2)]
> except (KeyError,TypeError):
> key = m.group(2)
> return dict.__getitem__(self, key)
>
>
> def __call__(self,key):
> return self.__getitem__(key)
>
> Variablesself 0x2...embership': }>dict.__getitem__ '__getitem__' of 'dict' objects>builtindictkey'_id'
>



-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


Re: [web2py] Error writing an auth_event

2012-02-02 Thread pbreit
I'm not really using memberships and I have auto group creation turned off:

auth.settings.create_user_groups = False

It works OK in my dev environment so it has something to do with my 
production data.

One thing I noticed is that it looks like it might be trying to validate 
NOT_IN_DB. Since it's a Profile update, it should certainly account for the 
current auth_user's email already being in the DB.



*File /opt/web2py/gluon/validators.py in __call__ at line 549* code 
arguments variables
Function argument list

(self=, value='pb@com')
Code listing

544.
545.
546.
547.
548.
549.

550.
551.
552.
553.

if len(rows) > 0:
if isinstance(self.record_id, dict):
for f in self.record_id:
if str(getattr(rows[0], f)) != str(self.record_id[f]):
return (value, translate(self.error_message))
elif str(rows[0]._id) != str(self.record_id):

return (value, translate(self.error_message))
return (value, None)



Re: [web2py] Re: Deploying on windows - login works locally but not remotely

2012-02-02 Thread Anthony
On Thursday, February 2, 2012 1:34:33 PM UTC-5, Jim S wrote:
>
>  You are good!
>
> Is this done because of a security concern?  Would 'best practice' dictate 
> that I not use the generic views.
>

Yes, it's a security concern. generic.json in particular will reveal 
everything passed to the view, including db fields that were selected but 
not intended to be exposed (e.g., the password field when selecting a user 
record) and variables intended only to implement logic within the view. 
It's generally safer to implement specific views or to enable generic views 
selectively (i.e., only the specific generic view needed for a specific 
function). This is discussed here: 
http://web2py.com/books/default/chapter/29/10#Generic-views.

Anthony 


Re: [web2py] Error writing an auth_event

2012-02-02 Thread Carlos Costa
Looking the code above, elif is hit when len(rows) = 0.
So I am stuck here, how could it retrive any value if the lenght is zero?
Must look this whole code to understand it.

2012/2/2 pbreit 

> I'm not really using memberships and I have auto group creation turned off:
>
> auth.settings.create_user_groups = False
>
> It works OK in my dev environment so it has something to do with my
> production data.
>
> One thing I noticed is that it looks like it might be trying to validate
> NOT_IN_DB. Since it's a Profile update, it should certainly account for the
> current auth_user's email already being in the DB.
>
>
>
> *File /opt/web2py/gluon/validators.py in __call__ at line 549* code
> arguments variables
> Function argument list
>
> (self=, value='pb@com')
> Code listing
>
> 544.
> 545.
> 546.
> 547.
> 548.
> 549.
>
> 550.
> 551.
> 552.
> 553.
>
> if len(rows) > 0:
> if isinstance(self.record_id, dict):
> for f in self.record_id:
> if str(getattr(rows[0], f)) != str(self.record_id[f]):
> return (value, translate(self.error_message))
>
> elif str(rows[0]._id) != str(self.record_id):
>
> return (value, translate(self.error_message))
> return (value, None)
>
>


-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


[web2py] Debugging in web2py

2012-02-02 Thread Web2Py Freak
Dear All ,

how can i use debugging in web2py are they any easy to use debugging
tools ?


Re: [web2py] Re: Deploying on windows - login works locally but not remotely

2012-02-02 Thread Jim Steil

Thanks again Anthony.  I will get that cleaned up.

-Jim

On 2/2/2012 1:46 PM, Anthony wrote:

On Thursday, February 2, 2012 1:34:33 PM UTC-5, Jim S wrote:

You are good!

Is this done because of a security concern?  Would 'best practice'
dictate that I not use the generic views.


Yes, it's a security concern. generic.json in particular will reveal 
everything passed to the view, including db fields that were selected 
but not intended to be exposed (e.g., the password field when 
selecting a user record) and variables intended only to implement 
logic within the view. It's generally safer to implement specific 
views or to enable generic views selectively (i.e., only the specific 
generic view needed for a specific function). This is discussed here: 
http://web2py.com/books/default/chapter/29/10#Generic-views.


Anthony


[web2py] Re: Debugging in web2py

2012-02-02 Thread Ross Peoples
Run web2py from console, and put "import pdb; pdb.set_trace()" right above 
the line of code where you want to start debugging. From there, use "n" to 
go to the next line, "s" to "step into" the next line, and "c" to continue 
execution.

Good luck!


[web2py] Re: Debugging in web2py

2012-02-02 Thread Ross Peoples
Forgot to mention that when the debugger pauses on a line of code, besides 
using the key commands mentioned before, you can run single-line Python 
commands as if you were in an interactive session.

This allows you to inspect variables and such. For example, once the 
debugger pauses and displays the (Pdb) prompt, you can type "print request" 
to print the entire contents of the request object to the console.


[web2py] Re: Debugging in web2py

2012-02-02 Thread Web2Py Freak
What i want to do is to use debugging in an application that i
integrated with PayPal and its working on Apache , i get some vars in
the url from paypal and am trying to save them in the database but
something happens   .. so any ideas how can i debug that !!


Re: [web2py] Re: Debugging in web2py

2012-02-02 Thread Mariano Reingart
With apache, you can try a remote debugger like winpdb.

I'm working on a simple approach for web2py based on a simple debugger
(qdb, an enhancement to pdb).

Please see the following page for further instructions:

http://code.google.com/p/rad2py/wiki/QdbRemotePythonDebugger

Basically:

* copy qdb.py to modules
* insert "import qdb; qdb.set_trace()" in your controller to start the debugger
* run "python qdb.py" from the command line to debug

The commands are very similar to pdb, you can evaluate expressions and
execute statements, set breakpoints, jump, etc.
If you need to connect from a remote machine, open the qdb.py file and
change the host address (currently it is 'localhost' port 3000 per
default)

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com



On Thu, Feb 2, 2012 at 6:22 PM, Web2Py Freak  wrote:
> What i want to do is to use debugging in an application that i
> integrated with PayPal and its working on Apache , i get some vars in
> the url from paypal and am trying to save them in the database but
> something happens   .. so any ideas how can i debug that !!


[web2py] Re: Server side validation with ajax but without form

2012-02-02 Thread Chris
Is there an equivalent of of validate_and_update for update_record?

[web2py] DAL Limitations with aggregate and union queries

2012-02-02 Thread BrendanC
I have a simple use case as follows:

Given an employee table containing names and salaries, I want to retrieve 
the highest and lowest salaries *AND* the corresponding employee info. 
Ideally I'd like to do this in a single database request since in the real 
world we like to minimize the number of round trips to the database and 
associated db connection requests. 

(BTW: getting a db connection can incur significant overhead unless some 
form of connection pooling is provided).

My solution (see test code below) creates a raw sql query that includes a 
'UNION' clause to combine 2 separate min/max queries and does in fact 
require just one db connection.

I'm wondering if it is possible to build this type of query using the DAL 
but I suspect it may not be possible (AFAIK the DAL and other ORM's do not 
support UNION's). I see 2 issues here that make this difficult with the DAL:

  1) In addition to the min/max values I also want the corrsponding record 
info in the result set
  2) At best the DAL may require 2 separate db requests

Any DAL guru's out there care to comment on this and provide an alternative 
DAL solution here.

TIA,

BrendanC


* DAL Sample Code 
***
'''
Example: Find min & max emp salaries and related name using SQL and Web2py 
DAL
'''

import os, sys

sdir = '/home/web2py'
sys.path.append(sdir)

try:
from gluon import DAL, Field
except ImportError as err:
print('gluon path not found')

# target db - sqlite
db = DAL("sqlite://emptest.db")

# define emp table
db.define_table('emp',
Field('name', type='string'),
Field('salary', type='double'),
migrate=True)

# define dict with test data 
empdict = {'adams': 10, 'gates': 5, 'jobs': 20, 'david': 12, 'williams': 35}

def populate_table():
# insert recs from dict into db
rcnt = 0
for (k,v) in empdict.iteritems():
ddict ={}
ddict['name'] = k
ddict['salary'] = v
print '>>> Inserting New Rec <<<'
try:
db.emp.insert(**ddict)
db.commit()
rcnt +=  1
except:
   #raise RuntimeError, 'Script error'
   print ' Insert Failed '
   print sys.exc_info()
   db.rollback()
print '\nAdded %s recs to emp table' %rcnt

if __name__ == "__main__":

import datetime
dtstart = datetime.datetime.now()
print '\nStarting at: %s \n' %dtstart.ctime()

print '\nDB Trace Info: Db uri: %s; DB Name: %s\n' %(db._uri, 
db._dbname)

#check rec count 
cnt = db(db.emp.id>0).count()
#print '>>> Emp Rec Count: %s' %cnt

#reload table
if cnt>0:
# deleting previous records
db(db.emp.id>0).delete()
populate_table()
 
#select min emp, salary
strsql_min = 'select name, salary from (select min(salary) as minsal 
from emp) as x ' + \
'inner join emp as t on t.salary = x.minsal'

strsql_max = 'select name, salary from (select max(salary) as maxsal 
from emp) as x ' + \
'inner join emp as t on t.salary = x.maxsal'


# Build a Union Query; returns a pair of dicts with min&max values
strsql =  strsql_min + ' UNION ' + strsql_max
rows = db.executesql(strsql, as_dict=True)

mindict = rows[0]
print '\n Lowest Salary:  Name: %s; \t Salary: %s' 
%(mindict['name'], mindict['salary'])

maxdict = rows[1]
print ' Highest Salary: Name: %s; \t Salary: %s\n' 
%(maxdict['name'], maxdict['salary'])

dtstop = datetime.datetime.now()
print '\nStopping at: %s \n' %dtstop.ctime()




[web2py] Hide fields in Forms...

2012-02-02 Thread Peter Pan
Hello,

want to hide certan Fields in Forms derived from Tables. I already tried 
everything but i cant make it happen.
Here's the link with my source code: http://pastebin.com/V8MAE4en

I already tried to set the Fields "parent" and "created_by" from the 
"task"-Table to "readable/writeable = False" but it does not seem to work.
I cant see what im doing wrong. Help is appreciated. Thanks


[web2py] problem with character encoding

2012-02-02 Thread peter
I am reading some text from a web site, using f=urllib.urlopen(),
and then s=f.read()

I then extract a bit of 's' as s1, s1 contains "Na Ponta Do Pé"

The é is encoded in a single byte as 0XE9.

If I do IS_SLUG.urlify(s1) it throws and error because 0XE9 is not a
valid character. I believe the encoding is ansii. I have tried all
manner of encoding and decoding but cannot get anything to work. If I
print s1 to the console or a file, then it works fine. But most python
character operations fail, presumably because they are expecting utf-8
which encodes é as two bytes.


If I do
s1="Na Ponta Do Pé"
IS_SLUG.urlify(s1)

There is no error.

Clearly I could check for 0XE9 and convert it uniquely, but I wonder
if anyone could suggest a conversion that would work for any ansii
character. I have googled and experimented a lot on this with no
success.

Thanks
Peter


Re: [web2py] problem with character encoding

2012-02-02 Thread Jonathan Lundell
On Feb 2, 2012, at 2:24 PM, peter wrote:

> I am reading some text from a web site, using f=urllib.urlopen(),
> and then s=f.read()
> 
> I then extract a bit of 's' as s1, s1 contains "Na Ponta Do Pé"
> 
> The é is encoded in a single byte as 0XE9.
> 
> If I do IS_SLUG.urlify(s1) it throws and error because 0XE9 is not a
> valid character. I believe the encoding is ansii. I have tried all
> manner of encoding and decoding but cannot get anything to work. If I
> print s1 to the console or a file, then it works fine. But most python
> character operations fail, presumably because they are expecting utf-8
> which encodes é as two bytes.
> 
> 
> If I do
> s1="Na Ponta Do Pé"
> IS_SLUG.urlify(s1)
> 
> There is no error.
> 
> Clearly I could check for 0XE9 and convert it uniquely, but I wonder
> if anyone could suggest a conversion that would work for any ansii
> character. I have googled and experimented a lot on this with no
> success.

The page you're reading is encoded as Latin-1. You need to decode it first.

[web2py] Re: problem with character encoding

2012-02-02 Thread peter
Thanks for the quick reply
s1=s1.decode('Latin-1')

does not help, is that what you had in mind?

Peter

On Feb 2, 10:38 pm, Jonathan Lundell  wrote:
> On Feb 2, 2012, at 2:24 PM, peter wrote:
>
>
>
>
>
>
>
>
>
> > I am reading some text from a web site, using f=urllib.urlopen(),
> > and then s=f.read()
>
> > I then extract a bit of 's' as s1, s1 contains "Na Ponta Do Pé"
>
> > The é is encoded in a single byte as 0XE9.
>
> > If I do IS_SLUG.urlify(s1) it throws and error because 0XE9 is not a
> > valid character. I believe the encoding is ansii. I have tried all
> > manner of encoding and decoding but cannot get anything to work. If I
> > print s1 to the console or a file, then it works fine. But most python
> > character operations fail, presumably because they are expecting utf-8
> > which encodes é as two bytes.
>
> > If I do
> > s1="Na Ponta Do Pé"
> > IS_SLUG.urlify(s1)
>
> > There is no error.
>
> > Clearly I could check for 0XE9 and convert it uniquely, but I wonder
> > if anyone could suggest a conversion that would work for any ansii
> > character. I have googled and experimented a lot on this with no
> > success.
>
> The page you're reading is encoded as Latin-1. You need to decode it first.


Re: [web2py] Re: problem with character encoding

2012-02-02 Thread Jonathan Lundell
On Feb 2, 2012, at 3:45 PM, peter wrote:

> Thanks for the quick reply
> s1=s1.decode('Latin-1')
> 
> does not help, is that what you had in mind?

Try 'latin-1'


Re: [web2py] Error writing an auth_event

2012-02-02 Thread pbreit
I moved "form = auth()" to the top of the function which seems to have 
fixed it (I have some other code in the user() function that required me to 
create the form before the return).

[web2py] Re: Debugging in web2py

2012-02-02 Thread pbreit
Logging is helpful.

https://groups.google.com/d/msg/web2py/CI5JGc8yZw8/K3v9nSWi2dYJ


[web2py] Re: Hide fields in Forms...

2012-02-02 Thread pbreit
This is a tricky one even for native English speakers: it's "writable".

Re: [web2py] Re: Server side validation with ajax but without form

2012-02-02 Thread Bruno Rocha
On Thu, Feb 2, 2012 at 7:59 PM, Chris  wrote:

> Is there an equivalent of of validate_and_update for update_record?


not yet, but it is was on roadmap, but I forgot to send the patch ( I guess
I have it here somewhere)

Row.validate_and_update_record()

I will try to find, but anyway it can be implemented based in
Table.validate_and_update

-- 

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


[web2py] Re: Minify (compress) response HTML

2012-02-02 Thread Kernc
Sorry for late reply, didn't get any notification by email due to my
list preferences. It could send me a follow-up on the thread I
posted... Oh, well...

Minification before gzipping still does make a difference:
this is my index.html:

$ wc -c minified.html
4827 minified.html
$ wc -c nonminified.html
74910 nonminified.html
$ gzip minified.html && wc -c minified.html.gz
2134 minified.html.gz
$ gzip nonminified.html && wc -c nonminified.html.gz
8247 nonminified.html.gz

Nearly 4-fold difference of minified&gzipped over non-
minified&gzipped. Not to mention minified HTML is faster and easier
for a browser to parse. And the minified-rendered views take up less
RAM when cache.ram'd (which is what one should do on nearly all
pages)

I would like the feature for its obfuscating nature. It hides the
implementation more, what is a loop, what is static html, how deep an
indentation goes...

It must be worth something, Google does it (view-source:https://
www.google.com/).

The implementation quoted in comment #2 (http://code.google.com/p/
web2py/issues/detail?id=369#c2) solves the issue quite well for me. I
haven't found any new bugs. It even minifies inline JS. It works. :-)
I renounce all rights to this code, which likely "belong" more to the
original inventor of this: 
http://packages.python.org/web2py_utils/output.html#compress-output
(As far as I am concerned, you can just use it.)

I agree a separate htmlminify module is an acceptable solution. :-)


[web2py] Re: problem with character encoding

2012-02-02 Thread peter
I did

On Feb 2, 11:58 pm, Jonathan Lundell  wrote:
> On Feb 2, 2012, at 3:45 PM, peter wrote:
>
> > Thanks for the quick reply
> > s1=s1.decode('Latin-1')
>
> > does not help, is that what you had in mind?
>
> Try 'latin-1'


[web2py] Re: problem with character encoding

2012-02-02 Thread peter
Okay, your telling me it was latin-1 was really useful. Following that
I did some more googling, and

s1=s1=s1.decode('Latin-1').encode('utf-8')

finally does the trick.

Thanks

Peter

On Feb 2, 11:58 pm, Jonathan Lundell  wrote:
> On Feb 2, 2012, at 3:45 PM, peter wrote:
>
> > Thanks for the quick reply
> > s1=s1.decode('Latin-1')
>
> > does not help, is that what you had in mind?
>
> Try 'latin-1'



[web2py] Re: problem with character encoding

2012-02-02 Thread peter
I of course mean
s1=s1.decode('Latin-1').encode('utf-8')

On Feb 3, 3:48 am, peter  wrote:
> Okay, your telling me it was latin-1 was really useful. Following that
> I did some more googling, and
>
> s1=s1=s1.decode('Latin-1').encode('utf-8')
>
> finally does the trick.
>
> Thanks
>
> Peter
>
> On Feb 2, 11:58 pm, Jonathan Lundell  wrote:
>
>
>
>
>
>
>
> > On Feb 2, 2012, at 3:45 PM, peter wrote:
>
> > > Thanks for the quick reply
> > > s1=s1.decode('Latin-1')
>
> > > does not help, is that what you had in mind?
>
> > Try 'latin-1'


[web2py] How to get a dropdown in self referencing table, create form?

2012-02-02 Thread Edward Shave
I have defined the following self referencing table.

db.define_table(
'account',
Field('name'),
Field('asset','boolean', default=False),
*Field('transfer','reference account'),*
format = '%(name)s',
singular = 'Account',
plural = 'Accounts',
)

How to get a drop down widget in create form for self referencing field?

I have seen talk of [represent], but need an example,

Any help will be much appreciated.

Ed



[web2py] Re: Minify (compress) response HTML

2012-02-02 Thread Massimo Di Pierro
OK, let's add a minifier in contrib.

On Feb 2, 8:16 pm, Kernc  wrote:
> Sorry for late reply, didn't get any notification by email due to my
> list preferences. It could send me a follow-up on the thread I
> posted... Oh, well...
>
> Minification before gzipping still does make a difference:
> this is my index.html:
>
> $ wc -c minified.html
> 4827 minified.html
> $ wc -c nonminified.html
> 74910 nonminified.html
> $ gzip minified.html && wc -c minified.html.gz
> 2134 minified.html.gz
> $ gzip nonminified.html && wc -c nonminified.html.gz
> 8247 nonminified.html.gz
>
> Nearly 4-fold difference of minified&gzipped over non-
> minified&gzipped. Not to mention minified HTML is faster and easier
> for a browser to parse. And the minified-rendered views take up less
> RAM when cache.ram'd (which is what one should do on nearly all
> pages)
>
> I would like the feature for its obfuscating nature. It hides the
> implementation more, what is a loop, what is static html, how deep an
> indentation goes...
>
> It must be worth something, Google does it 
> (view-source:https://www.google.com/).
>
> The implementation quoted in comment #2 (http://code.google.com/p/
> web2py/issues/detail?id=369#c2) solves the issue quite well for me. I
> haven't found any new bugs. It even minifies inline JS. It works. :-)
> I renounce all rights to this code, which likely "belong" more to the
> original inventor of 
> this:http://packages.python.org/web2py_utils/output.html#compress-output
> (As far as I am concerned, you can just use it.)
>
> I agree a separate htmlminify module is an acceptable solution. :-)


[web2py] Re: How to get a dropdown in self referencing table, create form?

2012-02-02 Thread Edward Shave
Found this works following definition

db.account.transfer.requires = IS_IN_DB(db,db.account.id,'%(name)s')