[web2py] Routes.py not working when deployed to GAE

2010-05-08 Thread Dane
Hello,

In my routes.py file, I have this line:

routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)

Working locally, if I go to http://localhost:8080/crossdomain.xml ,
the file is there.

However, when I upload to google app engine, 
http://www.mydomain.appspot.com/crossdomain.xml
gives a 404. The rest of the deployed app is working fine.

Any ideas?

Thanks,

Dane


[web2py] Re: Routes.py not working when deployed to GAE

2010-05-08 Thread Dane
I tried this. It works locally, but still having problems when
deployed. Now I'm getting a 500.

Here's the traceback:

: invalid syntax (, line 1)
Traceback (most recent call last):
  File "/base/data/home/apps/tthultimate/1.341813257625966505/
gaehandler.py", line 42, in 
import gluon.main
  File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
main.py", line 105, in 
rewrite.load()
  File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
rewrite.py", line 45, in load
raise e

On May 8, 5:05 pm, mdipierro  wrote:
> Can you try?
>
> routes_in = ((/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> On May 8, 11:58 am, Dane  wrote:
>
> > Hello,
>
> > In my routes.py file, I have this line:
>
> > routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> > Working locally, if I go tohttp://localhost:8080/crossdomain.xml,
> > the file is there.
>
> > However, when I upload to google app 
> > engine,http://www.mydomain.appspot.com/crossdomain.xml
> > gives a 404. The rest of the deployed app is working fine.
>
> > Any ideas?
>
> > Thanks,
>
> > Dane


[web2py] Re: Routes.py not working when deployed to GAE

2010-05-08 Thread Dane
Looks like the error is being raised in this block of rewrite.py.. is
this due to an attempt to interact with the file system?

def load(routes='routes.py'):
symbols = {}
if not os.path.exists(routes):
return
try:
routesfp = open(routes, 'r')
exec routesfp.read() in symbols
routesfp.close()
logging.info('URL rewrite is on. configuration in %s' %
routes)
except SyntaxError, e:
routesfp.close()
logging.error('Your %s has a syntax error. ' % routes + \
  'Please fix it before you restart web2py')
raise e

On May 8, 5:24 pm, Dane  wrote:
> I tried this. It works locally, but still having problems when
> deployed. Now I'm getting a 500.
>
> Here's the traceback:
>
> : invalid syntax (, line 1)
> Traceback (most recent call last):
>   File "/base/data/home/apps/tthultimate/1.341813257625966505/
> gaehandler.py", line 42, in 
>     import gluon.main
>   File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
> main.py", line 105, in 
>     rewrite.load()
>   File "/base/data/home/apps/tthultimate/1.341813257625966505/gluon/
> rewrite.py", line 45, in load
>     raise e
>
> On May 8, 5:05 pm, mdipierro  wrote:
>
> > Can you try?
>
> > routes_in = ((/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> > On May 8, 11:58 am, Dane  wrote:
>
> > > Hello,
>
> > > In my routes.py file, I have this line:
>
> > > routes_in = (('.*:/crossdomain.xml', '/init/static/crossdomain.xml'),)
>
> > > Working locally, if I go tohttp://localhost:8080/crossdomain.xml,
> > > the file is there.
>
> > > However, when I upload to google app 
> > > engine,http://www.mydomain.appspot.com/crossdomain.xml
> > > gives a 404. The rest of the deployed app is working fine.
>
> > > Any ideas?
>
> > > Thanks,
>
> > > Dane


[web2py] Re: Routes.py on GAE

2010-05-12 Thread Dane
Looks like same problem I've been having.

On May 10, 5:23 pm, Chris S  wrote:
> Does routes.py work on GAE?  I've recently deployed an app which used
> the 5-line routes.py from the book for routing robots.txt and
> favicon.icon.  I just wanted to get rid of that 100% error rate on
> those two files.  I recevied the following message.  Only after
> removing routes.py again did the app launch properly.
>
> begin error message
> #
> 05-10 01:18PM 34.771
> unable to import Rocket
>
> #
> E 05-10 01:18PM 34.774
> Your routes.py has a syntax error. Please fix it before you restart
> web2py
>
> #
> E 05-10 01:18PM 34.778
> : invalid syntax (, line 3)
> Traceback (most recent call last):
>   File "/base/data/home/apps/rms-solutions/beta.341858638445092536/
> gaehandler.py", line 44, in 
>     import gluon.main
>   File "/base/data/home/apps/rms-solutions/beta.341858638445092536/
> gluon/main.py", line 66, in 
>     rewrite.load()
>   File "/base/data/home/apps/rms-solutions/beta.341858638445092536/
> gluon/rewrite.py", line 63, in load
>     raise e


[web2py] Re: amfast rtmp example

2010-05-12 Thread Dane
Did you see the example of producer/consumer messaging on GAE? That's
killer.

On May 11, 12:26 am, mdipierro  wrote:
> you can already use pyqmf with web2py. I am not sure about rtmp. It is
> not a protocol that should be encouraged. http already provide range
> requests/partial content for streaming and it is not a proprietary
> protocol.
>
> Massimo
>
> On May 10, 11:21 pm, elffikk  wrote:
>
> > will it be hard to add this in 
> > web2py?http://code.google.com/p/amfast/source/browse/#svn/trunk/examples/mes...
>
> > or it is again a question for Tim? :)


[web2py] Re: Changing redirect for @auth.requires_login()

2010-02-03 Thread Dane
Thanks!

As an aside, I wonder why redirecting to the last accessed controller
function after login isn't the default behavior. Isn't this by far the
most common use case?

On Feb 3, 2:25 pm, Wes James  wrote:
> You will want to do it in your controller for each view function you have.
>
> I have some like this:
>
> if auth.is_logged_in():
>         redirect(URL(r=request,c='default',f='apage'))
>
> or something like
>
> @auth.requires_login()
> def change_password():
>     return 
> dict(form=auth.change_password(next=URL(r=request,c='default',f='apage')))
>
> db.py is used to set default behavior
>
> i.e.:
>
> auth.settings.register_next = URL(r=request,c='default',f='apage')
> auth.settings.login_next = URL(r=request,c='default',f='apage')
> auth.settings.logout_next = URL(r=request,c='default',f='apage')
>
> look in gluon/tools.py to see what the defaults are for many things.
>
> -wes
>
> On Wed, Feb 3, 2010 at 12:08 PM, Dane  wrote:
> > Thanks, but I still don't understand.. if I set it in db.py, won't
> > that permanently send all my login redirects to the same function? But
> > I want the redirect to change depending on the part of the site my
> > users try to access. Do I use a property on request for this?
>
> > On Feb 3, 1:53 pm, Wes James  wrote:
> >> db.py
>
> >> On Wed, Feb 3, 2010 at 11:12 AM, Dane  wrote:
> >> > Thanks, and where would I set this to get a redirect to the function
> >> > being accessed? In the body of the controller function itself? I'm new
> >> > to python and decorators, but I assumed nothing in the decorated
> >> > function would run.
>
> >> > On Feb 3, 10:37 am, mdipierro  wrote:
> >> >> auth.settings.login_next = URL(...)
>
> >> >> On Feb 3, 12:03 am, Dane  wrote:
>
> >> >> > Hey all, I've been using the @auth.requires_login() decorator and I
> >> >> > love the simplicity. It was also pretty easily to hook it into google
> >> >> > account authentication after a bit of searching on this group. My only
> >> >> > problem with it is I don't want users redirected to the index after
> >> >> > logging in, I'd like them to be redirected to the decorated controller
> >> >> > function they initially tried to access. Any ideas? Thanks.
>
> >> >> > -Dane
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "web2py-users" group.
> >> > To post to this group, send email to web...@googlegroups.com.
> >> > To unsubscribe from this group, send email to 
> >> > web2py+unsubscr...@googlegroups.com.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/web2py?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Adding

2010-02-04 Thread Dane
Hi,

I need to add a script block to the head of one of my templates (for
registering a flash object), and I'm a bit confused about how to
accomplish this since it doesn't seem like a good idea to mess with
the location of layout.html's {{include}}. This is the first time
since I've started with web2py that I've found myself missing a django
feature--blocks make this trivial. Ideas?

Thanks,

Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Adding

2010-02-04 Thread Dane
Thanks, I'll check it out.

On Feb 4, 9:45 am, DenesL  wrote:
> See section 5.4 in the book.
> It explains page layout including blocks.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Where do you use web2py?

2010-03-15 Thread Dane
I'm building an app for finding ultimate frisbee tournaments, leagues,
and pickup games by date, geographical proximity, and other criteria
on GAE with a Flex front end. Hope to eventually expand to team,
league, and tournament management with online payments, and add a play
diagramming tool and social media integration. It's challenging but
web2py makes it much less so.

On Mar 12, 4:42 am, "Giovanni Giorgi"  wrote:
> Hi all,
>  in the attempt to better knowing web2py and its community,
> I'd like to write some entry on my blog (gioorgi.com).
> I want to do a useful work for the community itself.
>
> This day I'd like to focus myself on the question: for which projects do
> you use web2py?
>
> I have seen the master project open sourced in the last few days
> posted by Asefa Debebe on 7th March (titled 'Relase of the first HL7 based
> on web2py framework', demo at ).
>
> So, how you are using web2py?
> For instance, do you prefer form-entry based application (data entry,
> CRM,etc) or community based one (like CMS, Facebook clone etc)?
>
> ciao ciao!
>
> --
> Team Leader
> Gioorgi.com Chief Editor

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] How to best design a date/geographic proximity query on GAE?

2010-03-26 Thread Dane
Hi all,

I'm building a directory for ultimate frisbee tournaments on GAE with
a Flex front end. The user selects a location, a radius, and a maximum
date. I have a basic version of this query implemented, but it's
inefficient and slow. One way I know I can improve it is by condensing
the many individual queries I'm using to assemble the objects into
bulk queries. I just learned that was possible from scanning the group
list. But I'm also thinking about a more extensive redesign that
utilizes memcache.

The main problem is that I can't query the datastore by location
because GAE won't allow multiple numerical comparison statements
(<,<=,>=,>) in one query. I'm already using one for date, and I'd need
TWO to check both latitude and longitude, so it's a no go. Currently,
my algorithm looks like this:

1.) Query by date and select
2.) Use destination function from geopy's distance module to find the
max and min latitude and longitudes for supplied distance
3.) Loop through results and remove all with lat/lng outside max/min
4.) Loop through again and use distance function to check exact
distance, because step 2 will include some areas outside the radius.
Remove results outside supplied distance (is this 2/3/4 combination
inefficent?)
5.) Assemble many-to-many lists and attach to objects (this is where I
need to switch to bulk operations)
6.) Return to client

Here's my plan for using memcache.. let me know if I'm way out in left
field on this as I have no prior experience with memcache or server
caching in general.

-Keep a list in the cache filled with "geo objects" that represent all
my data. These have five properties: latitude, longitude, event_id,
event_type (in anticipation of expanding beyond tournaments), and
start_date. This list will be sorted by date.

-Also keep a dict of pointers in the cache which represent the start
and end indices in the cache for all the date ranges my app uses (next
week, 2 weeks, month, 3 months, 6 months, year, 2 years).

-Have a scheduled task that updates the pointers daily at 12am.

-Add new inserts to the cache as well as the datastore; update
pointers.

Using this design, the algorithm would now look like:

1.) Use pointers to slice off appropriate chunk of list based on
supplied date.
2-4.) Same as above algorithm, except with geo objects
5.) Use bulk operation to select full tournaments using remaining geo
objects' event_ids
6.) Assemble many-to-manys
7.) Return to client

Thoughts on this approach? Many thanks for reading and any advice you
can give.

-Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Query by list of ids on GAE

2010-03-26 Thread Dane
Can this be done through the DAL? I see there is a get() method on
google.appengine.ext.db that can take multiple keys, but that syntax
confuses me.

-Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Query by list of ids on GAE

2010-03-27 Thread Dane
Hooray, I can contribute something! It's just a matter of converting
the ids to Key types with the Key.from_path method. google's db.get
takes a list of Keys.

import google.appengine.ext.db as gae

get_from_gae(idlist):

   keys = []

   for id in idlist:
  keys.append(gae.Key.from_path(table_name, id,
 _app=u'appname')

   return gae.get(keys)

On Mar 26, 11:50 pm, mdipierro  wrote:
> Not through the dal but if you find out how to do it using GAE API,
> post an example here and we can look into implementing it.
>
> Massimo
>
> On 26 Mar, 18:31, Dane  wrote:
>
> > Can this be done through the DAL? I see there is a get() method on
> > google.appengine.ext.db that can take multiple keys, but that syntax
> > confuses me.
>
> > -Dane
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Query by list of ids on GAE

2010-03-27 Thread Dane
Also the result objects use some sort of wrapper class, similar to the
web2py row object. Properties are accessed by dot syntax. Id is
accessed by result.key().id()

On Mar 27, 5:31 am, Dane  wrote:
> Hooray, I can contribute something! It's just a matter of converting
> the ids to Key types with the Key.from_path method. google's db.get
> takes a list of Keys.
>
> import google.appengine.ext.db as gae
>
> get_from_gae(idlist):
>
>    keys = []
>
>    for id in idlist:
>       keys.append(gae.Key.from_path(table_name, id,
>                  _app=u'appname')
>
>    return gae.get(keys)
>
> On Mar 26, 11:50 pm, mdipierro  wrote:
>
> > Not through the dal but if you find out how to do it using GAE API,
> > post an example here and we can look into implementing it.
>
> > Massimo
>
> > On 26 Mar, 18:31, Dane  wrote:
>
> > > Can this be done through the DAL? I see there is a get() method on
> > > google.appengine.ext.db that can take multiple keys, but that syntax
> > > confuses me.
>
> > > -Dane
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Integrating GeoModel on AppEngine

2010-03-30 Thread Dane
Hey all,

I need to do some geospatial queries for my current project.
Unfortunately, GAE doesn't allow multiple numerical comparisons in one
query, so proximity queries based on latitude/longitude columns are
out.

GeoModel to the rescue (http://code.google.com/p/geomodel/).

By extending GeoModel, a GAE entity gains a location property that can
be queried by distance/bounding box, etc. My question is how can I use
this in a web2py model?

Example code from http://code.google.com/p/geomodel/wiki/Usage :

from geo.geomodel import GeoModel

class MyEntity(GeoModel):
  foo = db.StringProperty()
  bar = db.IntegerProperty()


some_entity = MyEntity(location=db.GeoPt(37, -122),
   foo='Hello',
   bar=5)
...
some_entity.location = db.GeoPt(38, -122)
some_entity.update_location()
some_entity.put()


resuts = MyEntity.proximity_fetch(
 MyEntity.all().filter('bar <', 10),  # Rich query!
 geotypes.Point(39, -121),  # Or db.GeoPt
 max_results=10,
 max_distance=80467)  # Within 50 miles.


-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Get Auto-Generated Column Value on Insert or Update

2010-10-08 Thread Dane
Hello,

I have a db.table.insert and a db(query).update that both generate
timestamp columns. Is there a way for me to get the generated values
of these without hitting the db again?

Thanks.


[web2py] Validating Remote Data (from Flex)

2010-01-13 Thread Dane
Hello,

I've been learning Web2Py and liking it a lot. Thanks for your hard
work Mossimo. I want to use it as a backend for a site that will
mostly be in Flex. I've gotten the RPC working smoothly, and now I'm
onto validation. I'll be doing client-side validation on forms, but I
know serverside is also required for security and a second layer. I
first tried using form = crud.create(db.item) and then passing a
dictionary with keys corresponding to the item's model fields into the
form (i.e. form.accepts(flexItem) ), but this wasn't successful. I
tried accessing the form.errors to see what was wrong, but there
didn't seem to be any data contained here. I then switched to using
db.item.insert for insertion, and this added my item to the db, but
didn't perform any validation based on my model definition. I know I
could just write out the validation for each field manually, but I'm
wondering if there's a DRY method I could use instead. Thanks!

-Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




[web2py] Re: Validating Remote Data (from Flex)

2010-01-13 Thread Dane
Thank you. That worked like a charm.

On Jan 13, 1:10 pm, mdipierro  wrote:
> Try
>
> form.accepts(flexItem,formname=None)
>
> On Jan 13, 12:06 pm, Dane  wrote:
>
> > Hello,
>
> > I've been learning Web2Py and liking it a lot. Thanks for your hard
> > work Mossimo. I want to use it as a backend for a site that will
> > mostly be in Flex. I've gotten the RPC working smoothly, and now I'm
> > onto validation. I'll be doing client-side validation on forms, but I
> > know serverside is also required for security and a second layer. I
> > first tried using form = crud.create(db.item) and then passing a
> > dictionary with keys corresponding to the item's model fields into the
> > form (i.e. form.accepts(flexItem) ), but this wasn't successful. I
> > tried accessing the form.errors to see what was wrong, but there
> > didn't seem to be any data contained here. I then switched to using
> > db.item.insert for insertion, and this added my item to the db, but
> > didn't perform any validation based on my model definition. I know I
> > could just write out the validation for each field manually, but I'm
> > wondering if there's a DRY method I could use instead. Thanks!
>
> > -Dane
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




[web2py] Using XML templates with AMF

2010-01-29 Thread Dane
Hello,

I'm building a web2py backend for a Flex site, and I would like to
send some of my data as XML since it's hierarchical in nature and AS3
has great xml manipulation capabilities with e4x. However, I'd like to
send this data through an exposed amf function instead of through REST
for speed, security, and uniformity across my services. PyAMF has no
problem with XML, and I know I could use a tool like ElementTree to
build my xml right in the exposed function, but I'd rather use the
Web2py templating system. Any ideas on how I'd go about sending XML
generated through a template to Flex through an amf function?  Thanks!

-Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Using XML templates with AMF

2010-01-29 Thread Dane
Also note I'm running on GAE, in case that makes a difference.

On Jan 29, 6:44 pm, Dane  wrote:
> Hello,
>
> I'm building a web2py backend for a Flex site, and I would like to
> send some of my data as XML since it's hierarchical in nature and AS3
> has great xml manipulation capabilities with e4x. However, I'd like to
> send this data through an exposed amf function instead of through REST
> for speed, security, and uniformity across my services. PyAMF has no
> problem with XML, and I know I could use a tool like ElementTree to
> build my xml right in the exposed function, but I'd rather use the
> Web2py templating system. Any ideas on how I'd go about sending XML
> generated through a template to Flex through an amf function?  Thanks!
>
> -Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Using XML templates with AMF

2010-01-29 Thread Dane
Yes, I'm using services currently. My question is how do I return xml
generated by a template THROUGH a service. Sorry if I'm unclear or out
in left field. I'm still a beginner. The idea is something like this:

@service.amfrpc3('domain')
def somefunction(param):
  return dict(items = db(db.items.param == param).select())
   #this would return xml generated by associated template


#template for somefunction would look something like:


   {{for item in items}}

 
 {{=item.child}}

 







On Jan 29, 7:11 pm, mdipierro  wrote:
> Did you look into web2py services?
>
> @service.amfrpc3('domain')
> def somefunction(a,b,c):
>       return a+b+c
>
> On Jan 29, 5:44 pm, Dane  wrote:
>
> > Hello,
>
> > I'm building a web2py backend for a Flex site, and I would like to
> > send some of my data as XML since it's hierarchical in nature and AS3
> > has great xml manipulation capabilities with e4x. However, I'd like to
> > send this data through an exposed amf function instead of through REST
> > for speed, security, and uniformity across my services. PyAMF has no
> > problem with XML, and I know I could use a tool like ElementTree to
> > build my xml right in the exposed function, but I'd rather use the
> > Web2py templating system. Any ideas on how I'd go about sending XML
> > generated through a template to Flex through an amf function?  Thanks!
>
> > -Dane
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Using XML templates with AMF

2010-01-29 Thread Dane
Great, nice and simple. Thanks.

On Jan 29, 9:52 pm, Thadeus Burgess  wrote:
> @service.amfrpc3('domain')
> def somefunction(param):
>    return response.render(filename='mytemplate.xml', context=dict(items))
>
> -Thadeus
>
> On Fri, Jan 29, 2010 at 8:28 PM, Dane  wrote:
> > Yes, I'm using services currently. My question is how do I return xml
> > generated by a template THROUGH a service. Sorry if I'm unclear or out
> > in left field. I'm still a beginner. The idea is something like this:
>
> > @service.amfrpc3('domain')
> > def somefunction(param):
> >      return dict(items = db(db.items.param == param).select())
> >       #this would return xml generated by associated template
>
> > #template for somefunction would look something like:
>
> > 
> >   {{for item in items}}
>
> >     
> >         {{=item.child}}
>
> >     
>
> > 
>
> > On Jan 29, 7:11 pm, mdipierro  wrote:
> >> Did you look into web2py services?
>
> >> @service.amfrpc3('domain')
> >> def somefunction(a,b,c):
> >>       return a+b+c
>
> >> On Jan 29, 5:44 pm, Dane  wrote:
>
> >> > Hello,
>
> >> > I'm building a web2py backend for a Flex site, and I would like to
> >> > send some of my data as XML since it's hierarchical in nature and AS3
> >> > has great xml manipulation capabilities with e4x. However, I'd like to
> >> > send this data through an exposed amf function instead of through REST
> >> > for speed, security, and uniformity across my services. PyAMF has no
> >> > problem with XML, and I know I could use a tool like ElementTree to
> >> > build my xml right in the exposed function, but I'd rather use the
> >> > Web2py templating system. Any ideas on how I'd go about sending XML
> >> > generated through a template to Flex through an amf function?  Thanks!
>
> >> > -Dane
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Changing redirect for @auth.requires_login()

2010-02-02 Thread Dane
Hey all, I've been using the @auth.requires_login() decorator and I
love the simplicity. It was also pretty easily to hook it into google
account authentication after a bit of searching on this group. My only
problem with it is I don't want users redirected to the index after
logging in, I'd like them to be redirected to the decorated controller
function they initially tried to access. Any ideas? Thanks.

-Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Changing redirect for @auth.requires_login()

2010-02-03 Thread Dane
Thanks, and where would I set this to get a redirect to the function
being accessed? In the body of the controller function itself? I'm new
to python and decorators, but I assumed nothing in the decorated
function would run.


On Feb 3, 10:37 am, mdipierro  wrote:
> auth.settings.login_next = URL(...)
>
> On Feb 3, 12:03 am, Dane  wrote:
>
> > Hey all, I've been using the @auth.requires_login() decorator and I
> > love the simplicity. It was also pretty easily to hook it into google
> > account authentication after a bit of searching on this group. My only
> > problem with it is I don't want users redirected to the index after
> > logging in, I'd like them to be redirected to the decorated controller
> > function they initially tried to access. Any ideas? Thanks.
>
> > -Dane

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Changing redirect for @auth.requires_login()

2010-02-03 Thread Dane
Thanks, but I still don't understand.. if I set it in db.py, won't
that permanently send all my login redirects to the same function? But
I want the redirect to change depending on the part of the site my
users try to access. Do I use a property on request for this?

On Feb 3, 1:53 pm, Wes James  wrote:
> db.py
>
> On Wed, Feb 3, 2010 at 11:12 AM, Dane  wrote:
> > Thanks, and where would I set this to get a redirect to the function
> > being accessed? In the body of the controller function itself? I'm new
> > to python and decorators, but I assumed nothing in the decorated
> > function would run.
>
> > On Feb 3, 10:37 am, mdipierro  wrote:
> >> auth.settings.login_next = URL(...)
>
> >> On Feb 3, 12:03 am, Dane  wrote:
>
> >> > Hey all, I've been using the @auth.requires_login() decorator and I
> >> > love the simplicity. It was also pretty easily to hook it into google
> >> > account authentication after a bit of searching on this group. My only
> >> > problem with it is I don't want users redirected to the index after
> >> > logging in, I'd like them to be redirected to the decorated controller
> >> > function they initially tried to access. Any ideas? Thanks.
>
> >> > -Dane
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Changing redirect for @auth.requires_login()

2010-02-03 Thread Dane
Thanks, but I still don't understand.. if I set it in db.py, won't
that permanently send all my login redirects to the same function? But
I want the redirect to change depending on the part of the site my
users try to access. Do I use a property on request for this?

On Feb 3, 1:53 pm, Wes James  wrote:
> db.py
>
> On Wed, Feb 3, 2010 at 11:12 AM, Dane  wrote:
> > Thanks, and where would I set this to get a redirect to the function
> > being accessed? In the body of the controller function itself? I'm new
> > to python and decorators, but I assumed nothing in the decorated
> > function would run.
>
> > On Feb 3, 10:37 am, mdipierro  wrote:
> >> auth.settings.login_next = URL(...)
>
> >> On Feb 3, 12:03 am, Dane  wrote:
>
> >> > Hey all, I've been using the @auth.requires_login() decorator and I
> >> > love the simplicity. It was also pretty easily to hook it into google
> >> > account authentication after a bit of searching on this group. My only
> >> > problem with it is I don't want users redirected to the index after
> >> > logging in, I'd like them to be redirected to the decorated controller
> >> > function they initially tried to access. Any ideas? Thanks.
>
> >> > -Dane
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Web2py templates for HamlPY

2011-01-09 Thread Dane
Hey all, thought you might be interested to know that I just patched a
project HamlPy, a library for converting a pythonic haml-like syntax
to django templates/html, to work with web2py templates.

It allows for a less crufty, indentation-based syntax. Because it's
indentation-based, {{ pass }} is no longer needed to close flow-
control statements, and blocks are self-closed. Overall I think it's a
much cleaner and quicker way of creating templates. And if you do want
to use traditional {{ }} syntax, you can also do that in the .hamlpy
files and they'll be converted as-is.

https://github.com/danenania/HamlPy

Hope someone gets some use out of this. My first real open source
effort!


[web2py] Issues with DAL and MySQL on production (works locally)

2011-01-23 Thread Dane
Hello,

Today I got web2py running on EC2 and it wasn't too bad despite my
unix newbie status, but now I've run into a strange problem.

The app connects to a remote MySQL database. This database was
partially created and filled directly through MySQL, then we connected
web2py and let it manage further table creation and updates through
the DAL. This all went fine and it works locally, but on the EC2
server, web2py apparently isn't recognizing the tables that we
originally added through MySQL. Attempting to use these tables with
db[tablename] gives a KeyError. Tables that were automatically created
by web2py work fine.

All the the tables are set with 'fake_migrate=True'. On the server,
I've tried both syncing the database folders exactly, letting web2py
generate its own, and many combinations of these two with
migrate=True, fake_migrate=True, both omitted, migrate for the
original tables, fake for the others, etc. etc. No luck.

Any ideas?

-Dane


[web2py] Re: Issues with DAL and MySQL on production (works locally)

2011-01-23 Thread Dane
Thanks. Was planning to switch the db over at some point anyway, so
guess it might as well be now. Didn't realize mixing existing tables
with the DAL was such a no no.

On Jan 23, 10:03 am, Kenneth Lundström 
wrote:
> Two options:
>
> - if possible use an other database of the remote server and let web2py
> create all tables and then check whats different between those two databases
>
> - backup up data on remote server, drop database, create database, let
> web2py create tables and try to restore backup.
>
> Kenneth
>
> Hello,
>
>
>
>
>
>
>
> > Today I got web2py running on EC2 and it wasn't too bad despite my
> > unix newbie status, but now I've run into a strange problem.
>
> > The app connects to a remote MySQL database. This database was
> > partially created and filled directly through MySQL, then we connected
> > web2py and let it manage further table creation and updates through
> > the DAL. This all went fine and it works locally, but on the EC2
> > server, web2py apparently isn't recognizing the tables that we
> > originally added through MySQL. Attempting to use these tables with
> > db[tablename] gives a KeyError. Tables that were automatically created
> > by web2py work fine.
>
> > All the the tables are set with 'fake_migrate=True'. On the server,
> > I've tried both syncing the database folders exactly, letting web2py
> > generate its own, and many combinations of these two with
> > migrate=True, fake_migrate=True, both omitted, migrate for the
> > original tables, fake for the others, etc. etc. No luck.
>
> > Any ideas?
>
> > -Dane


[web2py] Re: Issues with DAL and MySQL on production (works locally)

2011-01-23 Thread Dane
Ok, now I have converted to a clean MySQL database (on EC2) so that
the tables are only generated by web2py. Then I ported the data and
set all the tables to migrate=False before uploading to the server,
and STILL I have the same exact issue. The tables that were originally
created through MySQL still generate key errors when I try to access
them through db, and all the others are fine. I tried restarting
apache and mysql. I tried deleting the working directory on the server
and re-cloning it. Tried deleting contents of databases, cache, and
sessions. And to top it off I just rebooted my instance, and suddenly
I can't ssh into it anymore. Ay caramba, not my day.


On Jan 23, 11:02 am, Kenneth Lundström 
wrote:
> I guess theoretically there is nothing wrong in creating tables and then
> writing the model files but in practise it can be quite hard to get them
> exactly correct.
>
> So either write model files for all tables and then let web2py create
> them or create tables in the database, import the table structure
> (web2py writes those model files based on how the tables look like) and
> then add own fields if needed.
>
> Kenneth
>
>
>
>
>
>
>
> > Thanks. Was planning to switch the db over at some point anyway, so
> > guess it might as well be now. Didn't realize mixing existing tables
> > with the DAL was such a no no.
>
> > On Jan 23, 10:03 am, Kenneth Lundstr m
> > wrote:
> >> Two options:
>
> >> - if possible use an other database of the remote server and let web2py
> >> create all tables and then check whats different between those two 
> >> databases
>
> >> - backup up data on remote server, drop database, create database, let
> >> web2py create tables and try to restore backup.
>
> >> Kenneth
>
> >> Hello,
>
> >>> Today I got web2py running on EC2 and it wasn't too bad despite my
> >>> unix newbie status, but now I've run into a strange problem.
> >>> The app connects to a remote MySQL database. This database was
> >>> partially created and filled directly through MySQL, then we connected
> >>> web2py and let it manage further table creation and updates through
> >>> the DAL. This all went fine and it works locally, but on the EC2
> >>> server, web2py apparently isn't recognizing the tables that we
> >>> originally added through MySQL. Attempting to use these tables with
> >>> db[tablename] gives a KeyError. Tables that were automatically created
> >>> by web2py work fine.
> >>> All the the tables are set with 'fake_migrate=True'. On the server,
> >>> I've tried both syncing the database folders exactly, letting web2py
> >>> generate its own, and many combinations of these two with
> >>> migrate=True, fake_migrate=True, both omitted, migrate for the
> >>> original tables, fake for the others, etc. etc. No luck.
> >>> Any ideas?
> >>> -Dane


[web2py] Detecting test vs. production environments

2011-02-01 Thread Dane
Hello, what's the best property to use on 'request' for determining
what environment the app is running in?  I've tried
request.env.remote_addr but it doesn't appear to be a reliable way to
distinguish. Currently I'm just using sys.platform since I'm
developing on windows and my server is linux--obviously this isn't
good for a lot of reasons, not least because I also need to
differentiate now between staging and production environments both on
the linux server.

Thanks.

-Dane


[web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Dane
I'm doing something similar for configuration, but I'd really like to
find a way to detect this setting automatically instead of setting a
flag which just adds needless complexity to my git deployments. All I
really need is a way to reliably check the full url of my app as the
client sees it, and I need it to be available when the first models
are being exec'd.

On Feb 2, 3:01 am, ron_m  wrote:
> I put all my production vs developer settings in an if else block and use my
> own variable PRODUCTION. This is in the model directory and named
> 0_customization.py in my case. This allows you to set the migrate,
> local_import reload parameter and anything else you want. Then I just need
> to remember to set the flag True or False depending on the situation.
>
> RMMV
>
> Ron


[web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Dane
Where does REMOTE_HOST live?

On Feb 2, 10:46 am, Vinicius Assef  wrote:
> Try to check the REMOTE_HOST.
>
> If it is "localhost", it is local.
>
>
>
>
>
>
>
> On Wed, Feb 2, 2011 at 6:09 AM, Dane  wrote:
> > I'm doing something similar for configuration, but I'd really like to
> > find a way to detect this setting automatically instead of setting a
> > flag which just adds needless complexity to my git deployments. All I
> > really need is a way to reliably check the full url of my app as the
> > client sees it, and I need it to be available when the first models
> > are being exec'd.
>
> > On Feb 2, 3:01 am, ron_m  wrote:
> >> I put all my production vs developer settings in an if else block and use 
> >> my
> >> own variable PRODUCTION. This is in the model directory and named
> >> 0_customization.py in my case. This allows you to set the migrate,
> >> local_import reload parameter and anything else you want. Then I just need
> >> to remember to set the flag True or False depending on the situation.
>
> >> RMMV
>
> >> Ron


[web2py] MySQL VARCHAR lengths not being set

2011-02-02 Thread Dane
Hello,

I have many fields defined like this:

Field('name','string', required=True, length=300,
requires=[IS_LENGTH(300)]),

where the VARCHAR length in MySQL is not being set properly. It is
defaulting to VARCHAR(255) for all strings regardless of my model
definitions. Is there something else I need to do or is this a bug in
the MySQL adapter?

Thanks.

-Dane


[web2py] Re: MySQL VARCHAR lengths not being set

2011-02-02 Thread Dane
Thank you. Fix from that thread did the trick.

On Feb 3, 1:02 am, Anthony  wrote:
> See this recent 
> discussion:https://groups.google.com/d/topic/web2py/tL8gnapo6fg/discussion
>
>
>
>
>
>
>
> On Thursday, February 3, 2011 12:39:45 AM UTC-5, Dane wrote:
> > Hello,
>
> > I have many fields defined like this:
>
> > Field('name','string', required=True, length=300,
> > requires=[IS_LENGTH(300)]),
>
> > where the VARCHAR length in MySQL is not being set properly. It is
> > defaulting to VARCHAR(255) for all strings regardless of my model
> > definitions. Is there something else I need to do or is this a bug in
> > the MySQL adapter?
>
> > Thanks.
>
> > -Dane


[web2py] Deleting a cookie

2011-02-06 Thread Dane
Hello,

I've got my own user system (not using Auth), and I'm trying to
implement a Remember Me option with cookies. It's working fine when
the user selects 'Yes' for remember me. Setting and detecting the
cookie is no problem, but I can't find a way to delete the cookie when
the user logs out or selects 'No'. Here's my code which attempts
everything I can think of.

if request.cookies.has_key('user'):
request.cookies['user'].clear()
del request.cookies['user']
print 'remove request user cookie'
if response.cookies.has_key('user'):
response.cookies['user'].clear()
del response.cookies['user']
print 'remove response user cookie'

After running this, request.cookies.has_key('user') is still returning
true and the cookie's data is still present.

Ideas? Thanks.


[web2py] Re: Getting started

2011-02-06 Thread Dane
I advise beginning with the book as it's pretty easy to follow and has
the most up-to-date documentation you'll find.

You can do some fairly cool stuff just following the patterns in the
book, but before attempting anything serious you should spend some
time studying and getting comfortable with python. It pays off very
quickly.

Ask lots of questions here. I think the main 'weakness' of web2py is
that it improves and gets new features too fast for documentation to
keep up, so stuff that you'll find through google, while it will
always work because web2py never breaks backward compatibility, has
often been deprecated by a better technique. Asking here, you almost
always get a quick and up-to-date response.

Also, once you learn the ropes, reading the source code of web2py
itself is often the best form of documentation you can find, and it's
also great to learn how such a powerful piece of software was
written.

On Feb 5, 11:05 pm, stargate  wrote:
> i was wondering if there a step by step tutorial that will show me how
> to build a web2py website.  Coming from php I am use to using includes
> how would I get started.


[web2py] Re: Django vs web2py pain points

2011-02-07 Thread Dane
In my opinion, the only advantages Django has are its admin interface
and the perks of a bigger and more established community, including
more stable documentation, better results when you google, a big
community on stack overflow, more name recognition (people won't
hesitate to let you do their project in Django because they've heard
of it, you have to convince them with web2py).

Some of these things have a fairly big impact, but overall web2py is
much simpler, more powerful, and gives you less headaches. If you're
willing to be more adventurous in terms of sifting through discussion
threads and google results and digging through the source instead of
usually finding a blog post that explains what you need to do, you
definitely get a major reward for working with web2py. Once you find
out how to do something, it's almost always simple and elegant. It can
just be hard to find out about it.

As far as being ready for production, it's doing fine on my vps after
following a few simple tutorials. I don't know how it scales yet, but
I think Massimo knows his stuff as well as the Django crew. And
doesn't choosing Python in the first place indicate priorities other
than raw speed? Developer productivity is a much more important factor
for the vast majority of sites, even ones with potential to be fairly
popular.

On Feb 6, 10:36 am, Luther Goh Lu Feng  wrote:
> Hi all,
>
> I am about to have a constructive discussion about web2py vs django
> with a team member of mine before we decide whether to implement a
> project. He is an expert with django while I consider myself an
> intermediate web2py user.
>
> This is not a flamebait, but I would like to mainly hear pain points
> about web2py and django, so that we can make a good decision. I am
> only familiar with web2py, and only brushed the surface of django.
>
> Thanks in advance.


[web2py] Re: Deleting a cookie

2011-02-07 Thread Dane
Thanks.

On Feb 7, 9:28 am, Massimo Di Pierro 
wrote:
> http://msdn.microsoft.com/en-us/library/ms178195.aspx
>
> "You cannot directly delete a cookie on a user's computer. However,
> you can direct the user's browser to delete the cookie by setting the
> cookie's expiration date to a past date. The next time a user makes a
> request to a page within the domain or path that set the cookie, the
> browser will determine that the cookie has expired and remove it."
>
> On Feb 7, 1:28 am, Dane  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I've got my own user system (not using Auth), and I'm trying to
> > implement a Remember Me option with cookies. It's working fine when
> > the user selects 'Yes' for remember me. Setting and detecting the
> > cookie is no problem, but I can't find a way to delete the cookie when
> > the user logs out or selects 'No'. Here's my code which attempts
> > everything I can think of.
>
> > if request.cookies.has_key('user'):
> >         request.cookies['user'].clear()
> >         del request.cookies['user']
> >         print 'remove request user cookie'
> > if response.cookies.has_key('user'):
> >         response.cookies['user'].clear()
> >         del response.cookies['user']
> >         print 'remove response user cookie'
>
> > After running this, request.cookies.has_key('user') is still returning
> > true and the cookie's data is still present.
>
> > Ideas? Thanks.


[web2py] Re: Deleting a cookie

2011-02-07 Thread Dane
Ok, now I'm using this code:

for r in [request, response]:
if r.cookies.has_key('user'):
r.cookies['user']['expires'] =
datetime.datetime.strftime(datetime.datetime(2011,1,1,0,0), "%a, %d-%b-
%Y %H:%M:%S GMT")
print 'remove %s user cookie' % ('request' if r == request
else 'response')

And still my cookie isn't going away...

On Feb 7, 9:28 am, Massimo Di Pierro 
wrote:
> http://msdn.microsoft.com/en-us/library/ms178195.aspx
>
> "You cannot directly delete a cookie on a user's computer. However,
> you can direct the user's browser to delete the cookie by setting the
> cookie's expiration date to a past date. The next time a user makes a
> request to a page within the domain or path that set the cookie, the
> browser will determine that the cookie has expired and remove it."
>
> On Feb 7, 1:28 am, Dane  wrote:
>
>
>
>
>
>
>
> > Hello,
>
> > I've got my own user system (not using Auth), and I'm trying to
> > implement a Remember Me option with cookies. It's working fine when
> > the user selects 'Yes' for remember me. Setting and detecting the
> > cookie is no problem, but I can't find a way to delete the cookie when
> > the user logs out or selects 'No'. Here's my code which attempts
> > everything I can think of.
>
> > if request.cookies.has_key('user'):
> >         request.cookies['user'].clear()
> >         del request.cookies['user']
> >         print 'remove request user cookie'
> > if response.cookies.has_key('user'):
> >         response.cookies['user'].clear()
> >         del response.cookies['user']
> >         print 'remove response user cookie'
>
> > After running this, request.cookies.has_key('user') is still returning
> > true and the cookie's data is still present.
>
> > Ideas? Thanks.


[web2py] Bypassing tickets in development

2011-02-08 Thread Dane
Would it be possible to set a flag for bypassing the ticketing system
and just displaying errors on the page during development?

The current system is nice for production, but it's a bit of hassle to
go through two extra links and enter a password just to see the error
trace in development.

-Dane


[web2py] Re: Bypassing tickets in development

2011-02-08 Thread Dane
Ok, I'll look into the code and see if I can handle it.

On Feb 8, 8:04 pm, selecta  wrote:
> there was already a suggestion for that,
> the answer was to take the methods for displaying the tickets and
> displaying the ticket content instead of the link if the user has the
> right permissions, should be straight forward for somebody a bit into
> the web2py code
> unfortunately nobody had time/interest yet to implement it
> i would love to have it too but also no time currently, so keep
> bugging until somebody finally implements it or do it yourself
> i remember that massimo said he also likes the idea :D
>
> On Feb 9, 1:29 am, Dane  wrote:
>
>
>
>
>
>
>
> > Would it be possible to set a flag for bypassing the ticketing system
> > and just displaying errors on the page during development?
>
> > The current system is nice for production, but it's a bit of hassle to
> > go through two extra links and enter a password just to see the error
> > trace in development.
>
> > -Dane


[web2py] Re: Test if client has javascript

2011-02-09 Thread Dane
Make an ajax call on page load and set a session variable if the call
gets through (session.has_js = True).

On Feb 9, 3:33 am, "ma...@rockiger.com" 
wrote:
> I am using disqus as comment system. This only works for client that have
> javascript enabled.
> I am programming a fallback for clients that don't have javascript (esp.
> Google).
>
> I am curios, if there is a way, to see if javascript is enabled on the
> client making a request to a website?
> This way I could save on database requests
>
> Regards,
> Marco


[web2py] Cache.disk() expiring unexpectedly

2011-02-10 Thread Dane
I'm trying to use cache.disk to cache a large TABLE object
indefinitely. It seems to work fine at first, but then expires after a
couple minutes.

I'm setting it like this:

cache.disk.clear('^%s$' % cache_key)
cache.disk(cache_key, lambda:grid, None)

*(I also tried 10**10 instead of None for duration with same result)

And I'm accessing like this:

cached = cache.disk(cache_key, lambda:None)
if cached: return cached

-Dane


[web2py] Re: Cache.disk() expiring unexpectedly

2011-02-10 Thread Dane
This is in my development environment on Windows 7 by the way.

On Feb 10, 7:17 am, Dane  wrote:
> I'm trying to use cache.disk to cache a large TABLE object
> indefinitely. It seems to work fine at first, but then expires after a
> couple minutes.
>
> I'm setting it like this:
>
> cache.disk.clear('^%s$' % cache_key)
> cache.disk(cache_key, lambda:grid, None)
>
> *(I also tried 10**10 instead of None for duration with same result)
>
> And I'm accessing like this:
>
> cached = cache.disk(cache_key, lambda:None)
> if cached: return cached
>
> -Dane


[web2py] Re: custom form without using database?

2011-02-10 Thread Dane
What about widgets? IS_IN_DB() for example. Is there a way to get
those working with a regular FORM without using SQLFORM?

On Feb 10, 8:22 am, Bruno Rocha  wrote:
> I almost always use forms in this following way:
>
> 
>
> *#Create a DIV to WRAP it all*>>> div = DIV(FORM())
> >>> print div
>
>  method="post">
>
> *#Take the elements of the wrapper using DOM*>>> print div.element('form')
>
> 
>
> *#Create some other objects*>>> table = TABLE()
> >>> table.append(TR(TD(INPUT(_type='text',requires=IS_NOT_EMPTY()
> >>> print table
>
> 
>
> *#Append other objects to the wrapper*>>> div.element('form').append(table)
> >>> print div
>
>  method="post"> />
>
> *#validators works well*>>> 
> div.element('form').element(_type='text')['requires']
>
> 
>
> 
>
> Note that it will work even if you want to use SQLFORM.
>
> --
> Bruno Rochahttp://about.me/rochacbruno/bio


[web2py] Re: Cache.disk() expiring unexpectedly

2011-02-10 Thread Dane
Thanks, make sense.

This could use a bit better explanation in the book.

On Feb 10, 9:23 am, Massimo Di Pierro 
wrote:
> The problem is here:
>
> cached = cache.disk(cache_key, lambda:None)
>
> The expiration time is not set by the initial call but it is set but
> each retrieve call. It is the retrieve call above that decided whether
> the stored value should be considered expired or not. Since you are
> not specifying a time expire you get the default 300seconds (5
> minutes) and then you override it the return of lambda:None, i.e.
> None. Should be:
>
> cached = cache.disk(cache_key, lambda:None, None)
>
> On Feb 10, 6:17 am, Dane  wrote:
>
>
>
>
>
>
>
> > I'm trying to use cache.disk to cache a large TABLE object
> > indefinitely. It seems to work fine at first, but then expires after a
> > couple minutes.
>
> > I'm setting it like this:
>
> > cache.disk.clear('^%s$' % cache_key)
> > cache.disk(cache_key, lambda:grid, None)
>
> > *(I also tried 10**10 instead of None for duration with same result)
>
> > And I'm accessing like this:
>
> > cached = cache.disk(cache_key, lambda:None)
> > if cached: return cached
>
> > -Dane


[web2py] JSON in templates

2011-02-10 Thread Dane
Hi,

Is there any easy way to embed JSON directly into templates? I've been
trying a bunch of different methods and nothing seems to work due to
quote escaping. I'd rather not create a separate controller function
or loop through JSON structure myself just to output a simple object.
Ideas? This would be a very powerful feature if it worked
straightforwardly. Thanks.

-Dane


[web2py] Re: JSON in templates

2011-02-10 Thread Dane
On a more general note, it seems like tighter and tighter integration
with the client and javascript, potentially even to the point of
making it a first class citizen like db, would perhaps be one of the
best directions web2py could go in my eyes.

On Feb 10, 11:14 pm, Dane  wrote:
> Hi,
>
> Is there any easy way to embed JSON directly into templates? I've been
> trying a bunch of different methods and nothing seems to work due to
> quote escaping. I'd rather not create a separate controller function
> or loop through JSON structure myself just to output a simple object.
> Ideas? This would be a very powerful feature if it worked
> straightforwardly. Thanks.
>
> -Dane


[web2py] When is db.commit() unnecessary?

2011-02-12 Thread Dane
Hello, wondering if someone could clarify when it's unnecessary to
call db.commit()? I've noticed it is needed when doing inserts from
the console, but it seems to be implicit in controller functions? Just
looking for some quick clarification on this. Thanks!


[web2py] Re: When is db.commit() unnecessary?

2011-02-12 Thread Dane
Thanks, that is helpful.

On Feb 12, 6:05 pm, Massimo Di Pierro 
wrote:
> every http request works like this:
>
> try:
>    run all models
>    run controller function
>    run view
>    commit all open trasactions
> except:
>    rollback all open transactions
>
> So in models, controllers and views only you need to db.commit() if
> you want to commit despite possible uncaught exceptions later in the
> same actions.
>
> If you use DAL in a script you always need to do db.commit()
>
> On Feb 12, 4:19 pm, Dane  wrote:
>
>
>
>
>
>
>
> > Hello, wondering if someone could clarify when it's unnecessary to
> > call db.commit()? I've noticed it is needed when doing inserts from
> > the console, but it seems to be implicit in controller functions? Just
> > looking for some quick clarification on this. Thanks!


[web2py] Async http request in web2py

2011-02-17 Thread Dane
Hi,

I need to make an asynchronous http request to one of my controller
functions in order to some lightweight background processing
(refreshing some cached objects). I came upon this thread:

http://groups.google.com/group/web2py/browse_thread/thread/bbe66f10843d6228/af4d1c0e8e8937d2?lnk=gst&q=web2py+async+http+request#af4d1c0e8e8937d2

But the link to the "lola" function posted post by Massimo is broken.
Can anyone supply a new link or explain a simple way to make async,
ajax-like requests from within web2py? Thanks.

-Dane


[web2py] Re: Async http request in web2py

2011-02-18 Thread Dane
Synchronous http makes the call and stops further execution until the
result is returned.

Async makes the call and optionally provides a callback so that
further code can be executed while waiting for the response. The way
ajax calls with in javascript, for example.

Seems like basic functionality--strange that something so useful isn't
built in to python in a straightforward way. It would be great if
web2py could do something to address this. There are many use cases
and it's much easier and lighter weight than dealing with threads,
processes, cron, etc. when all that is needed is a quick non-blocking
call.

On Feb 18, 8:52 am, KMax  wrote:
> asynchronous http and synchronous http
> What the difference ?
> On 18 фев, 10:37, Dane  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I need to make an asynchronous http request to one of my controller
> > functions in order to some lightweight background processing
> > (refreshing some cached objects). I came upon this thread:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> > But the link to the "lola" function posted post by Massimo is broken.
> > Can anyone supply a new link or explain a simple way to make async,
> > ajax-like requests from within web2py? Thanks.
>
> > -Dane


[web2py] Re: Async http request in web2py

2011-02-18 Thread Dane
Thanks for the explanation Massimo. I figured it must be an issue with
python's architecture or something would have been added to the std
lib by now.

It's easy enough to simulate this behavior with ajax calls to
controllers from the client. Unfortunately since you can't rely on
javascript being enabled, it can't be used in every situation. Sort of
peculiar how a browser on the client's computer is more capable in
this area than a powerful web server.

It would be neat if someone set up a publish/subscribe api that could
act as an async proxy for synchronous servers. You would make a
request that included a target url and a callback url. Maybe something
like this already exists?


On Feb 18, 11:31 pm, Massimo Di Pierro 
wrote:
> It is more complex than this. It is about two different models to
> handle concurrency.
>
> In one model you have one thread per request. Each request does IO
> with the client within one thread. The web server creates and manages
> the threads connects the thread to the web app (for example web2py)
> via mod_wsgi.
>
> In another model you do not have threads. You have async IO. It allows
> to serve more clients at the same time if the requests are really
> simple. If the computation is significative you may have concurrency
> issues.
>
> Then you can heve async io with ligthweight thread within is the best
> of both worlds.
>
> Python does not have built-in lightweight threads. web2py is based on
> mod_wsgi which does not support async.
>
> Anyway, this is not a definitive word on the subject.
>
> Massimo
>
> On Feb 18, 9:15 pm, Dane  wrote:
>
>
>
>
>
>
>
> > Synchronous http makes the call and stops further execution until the
> > result is returned.
>
> > Async makes the call and optionally provides a callback so that
> > further code can be executed while waiting for the response. The way
> > ajax calls with in javascript, for example.
>
> > Seems like basic functionality--strange that something so useful isn't
> > built in to python in a straightforward way. It would be great if
> > web2py could do something to address this. There are many use cases
> > and it's much easier and lighter weight than dealing with threads,
> > processes, cron, etc. when all that is needed is a quick non-blocking
> > call.
>
> > On Feb 18, 8:52 am, KMax  wrote:
>
> > > asynchronous http and synchronous http
> > > What the difference ?
> > > On 18 фев, 10:37, Dane  wrote:
>
> > > > Hi,
>
> > > > I need to make an asynchronous http request to one of my controller
> > > > functions in order to some lightweight background processing
> > > > (refreshing some cached objects). I came upon this thread:
>
> > > >http://groups.google.com/group/web2py/browse_thread/thread/bbe66f1084...
>
> > > > But the link to the "lola" function posted post by Massimo is broken.
> > > > Can anyone supply a new link or explain a simple way to make async,
> > > > ajax-like requests from within web2py? Thanks.
>
> > > > -Dane


[web2py] Re: Problem with www-data ownership (or lack thereof)

2011-02-19 Thread Dane
Does fabric/mercurial have post-receive hooks like git? I use this do
a recursive chown after every update to be safe.

On Feb 18, 11:54 pm, pbreit  wrote:
> I just had a site outage after deploying some code changes. Somehow, some of
> my directories and files had become owned by root instead of www-data which
> apparently denied some sort of access. I'm not exactly sure how it happens
> and what the deal is with www-data.
>
> I'm running Cherokee on Ubuntu. For deployment I use fabric to hg pull from
> bitbucket.
>
> I forgot which forlders/files were affected because I did a recursive chown
> on the whole directory. Can anyone help me understand the need for www-data
> ownership and how to make sure my files/folders remain properly owned.
> Thanks.


[web2py] Problem with models in subdirectories

2011-06-20 Thread Dane
Hello, I'm migrating an app to a new server (ubuntu 10.10) and
upgraded to the most newest web2py stable version as part of this.
This has introduced a problem where models in subdirectories of the
model folder don't seem to be getting executed. Files placed directly
in the model folder run correctly.  I have done a 'chown www-data . -
R'

Any ideas?


[web2py] Re: Problem with models in subdirectories

2011-06-20 Thread Dane
I see... any ideas for a quick method to force all models in
subfolders to run? I have dozens of model files organized in various
subfolders and I'd rather avoid lumping them all together. Thanks for
the help.

On Jun 20, 3:41 pm, Anthony  wrote:
> 1.96 introduced conditional models -- so model files in subfolders will only
> run if the name of the subfolder matches the name of the currently requested
> controller (you can also add an additional level of subfolders to match
> function names within controllers). Prior to 1.96, I don't think using
> subfolders in /models was officially supported.
>
> Anthony
>
>
>
>
>
>
>
> On Monday, June 20, 2011 3:29:24 PM UTC-4, Dane wrote:
> > Hello, I'm migrating an app to a new server (ubuntu 10.10) and
> > upgraded to the most newest web2py stable version as part of this.
> > This has introduced a problem where models in subdirectories of the
> > model folder don't seem to be getting executed. Files placed directly
> > in the model folder run correctly.  I have done a 'chown www-data . -
> > R'
>
> > Any ideas?


[web2py] Re: What is the best deployment method.

2011-08-05 Thread Dane
For me git + simple sh hooks has been an easy and effective method.

On Aug 6, 12:18 am, Jason Brower  wrote:
> I see three places that I have to work in a modern team based development.
> Local Machine: Where I host my own server and settings.
> Testing Machine: Server that should mimic live production to work out
> any details.
> Production: Server with publicly available sites and where data kept
> vital over everything else.
>
> What is the best recommended way to push a web2py application to deployment?
> Personally, I think it would be nice to have a way to do that from the
> web2py framework itself.
> I am sure there is a way to only allow certain connections into the
> deployment site. Amazon cloud does it, why couldn't we do it. For
> example some kind of package verification on upload to make sure the
> package has come from the right place.
>
> Best Regards,
> Jason Brower


[web2py] Re: looking for volunteers to help proof-read book 5th ed.

2013-01-27 Thread Dane Wright
Some minor corrections -

Line 1724 - change 'browser' to 'browse' and add 'one' 
from: 
+Line 38 creates a ``grid`` object that allows to browser, add and update 
the comments linked to a page.
to:
+Line 38 creates a ``grid`` object that allows one to browse, add and 
update the comments linked to a page.

Line 12921 - add 'to'  
from:
+Attention: grid and smartgrid were experimental prior web2py version 2.0 
.
to:
+Attention: grid and smartgrid were experimental prior to web2py version 
2.0 .

Line 12924 - change 'browser' to 'browse'
from:
+These are two high level gadgets that create complex CRUD controls. They 
provide pagination, the ability to browser, search, sort, create, update 
and delete records from a single gadgets.
to:
+These are two high level gadgets that create complex CRUD controls. They 
provide pagination, the ability to browse, search, sort, create, update and 
delete records from a single gadgets.

Dane

On Sunday, 20 January 2013 23:52:02 UTC, Massimo Di Pierro wrote:
>
> I am looking for help proofreading the final version of the book. It is 
> almost done up to a final touch. 
>
> The attached file contains the changes between the 4th edition and 5th 
> edition (only the new text). It would be great is some native english 
> speaker could be me proof-read the changes. If you can help please edit the 
> text in place with a text editor, without adding line breaks or extra 
> spaces so I can diff the corrections. 
>
> The first two people who volunteer to help and can proof-read the attached 
> file by Saturday, will receive a free copy of the printed book as soon as 
> it is done. 
>
> Massimo 
>
>
>

-- 





[web2py] Re: looking for volunteers to help proof-read book 5th ed.

2013-01-28 Thread Dane Wright
A few minor typos -

Line 17178 under WingIDE, Rad2Py, and Eclipse - change 'execued' to 
'executed' 
from: 
+it does not change the logic as this is never execued but it forces the 
IDE to parse it and understand where the objects in the global namespace 
come from (the ``gluon`` module) thus making autocompletion work.
to:
+it does not change the logic as this is never executed but it forces the 
IDE to parse it and understand where the objects in the global namespace 
come from (the ``gluon`` module) thus making autocompletion work.

Line 17200 under Publishing a folder - change 'fiels' to 'files' 
from: 
+which you can render in a view with ``{{=fiels}}``. 
to:
+which you can render in a view with ``{{=files}}``.

I'm not sure whether text under Google Wallet is being updated in the new 
edition but the current 4.9 edition has a few missing or incorrect  words 
(proposed text shown below in CAPS) -

"If you want a tighter integration, you have to use the Level 2 
notification API. In that case you can pass more information to Google and 
Google will call your API to notify about purchases. This allows you to 
keep accounting information within your application but it requires you TO 
expose web services that can talk to Google Wallet.

This is a considerable -> CONSIDERABLY more difficult problem but such AN 
API has already been implemented and it is available as A plugin from ."

and under Stripe.com:

"Stripe also allows you TO verify a transaction at a later time:"

Dane

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Access MySQL PythonAnywhere

2013-06-18 Thread Dane Wright
Yes I use MySQL on PythonAnywhere and so far it is working well. Can you 
describe your problem in more detail?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] How to get the file name when importing a csv file?

2013-06-23 Thread Dane Wright
I'm importing a lot of csv files through Database Administration and would like 
to be reminded of which one was last imported.

I was going to amend appadmin.py so that the response.flash on line 255 said 
"data uploaded for "+filename. But I just can't see where the filename is 
stored. I can see that it is in response.vars.csvfile but I'm not sure how to 
get it out of there - response.vars.csvfile.name just gives "csvfile".

Thanks

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to get the file name when importing a csv file?

2013-06-24 Thread Dane Wright
Anthony - thank you very much - that works perfectly!

Is this documented somewhere that I could have looked up myself?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: max size table that DAL can handle?

2015-03-16 Thread Dane Wright
I have a table which currently contains 10m+ records (local government 
spending in www.appgov.org). A native SQL count(*) will take 3-5 secs but 
 reading all the records like this via the DAL will result in the system 
hanging. I try not to read too many of these records in any one online 
transaction by allowing only selections and calculating subtotals offline. 
I also create MySQL indexes outside of Web2py to speed things up where 
necessary. Of course I also can't ever say db.laspend.id>0 in the Database 
Admin facility either!

>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.