Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread pbreit
Are you getting an error? What is working fine? What are these: "__view(parameters), __feed(parameters), __result(parameters)"? A suggestion would be to skip the ajax and paging for now. That can complicate things and is not really necessary. Keep things as simple as possible.

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
pardon me, i just follow the example that was written on the book: http://web2py.com/book/default/chapter/03 and it works fine, but i want to make it simple, i mean create __view(parameters), __feed(parameters), __result(parameters), and then the other function call it and pass the arguments.

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread pbreit
That code has *lots* of problems. First, there's no db() call so you're not going to have any rows. You don't do the "onkeyup" like that. You need to do it in the view as shown in the book: http://web2py.com/book/default/chapter/10#The-ajax-Function You're going to have a problem if "len(reques

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
thank you so much for your explaination. pardon, because i'm a newbie in python n web2py, i just learn, try to implement what have been written in the http://web2py.com/book/default/ the other controller that can't be passed is *blog_result* like on below : def bl

[web2py] Re: why connect to remote a DB when you can ....

2011-04-09 Thread mart
Sure, I'm think I should maybe put a doc to this (so I don't forget as well). Is there anything specific you are interested in? Mart :) On Apr 9, 3:55 pm, bobv wrote: > Hey Mart: > > I am extremely interested on your idea. This will save me time > figuring it out. Please teach me how to do it on

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread pbreit
T() is for text translations and I'm not sure you can use it (or would want to) with non-static text. That dict() looks a little messy. For one thing, you can simply include blogs=blogs. Some of those things I would put in the view instead (MARKMIN(().xml(), URL('blog_show')). Also, since views

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
hi, all, thank you so much for your detail explaination, i'm understand right now. i can simplified the other function (show and view) but for search result and feed, i can't pass it to another function. 1. why i can't pass row.title into variable? def blog_result(): pattern = '%' + request.vars

[web2py] Re: Problem with JQuery Function

2011-04-09 Thread pbreit
That code snippet is missing a }.

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Serbitar
Strange. My example from earlier does not work. It returns always the last call from func. list = ["a","b","c","d"] fields = [] for entry in list: fields += [Field(entry, type="string")] db.define_table('test', *fields) class MyVirtualFields(object): pass for entry in list: def func

[web2py] Problem with JQuery Function

2011-04-09 Thread luifran
I entered in web2py_ajax.html the following code to submit the form by pressing the Enter key: $ (function () { $ ("form"). bind ("keypress", function (event) { if (event.keyCode == 13) { $ ('form'). submit () } }); The pr

Re: [web2py] Re: T usage

2011-04-09 Thread Stifan Kristi
Hi, is it possible to translate the output data table using T()? thank you so much On Sun, Apr 10, 2011 at 5:45 AM, niknok wrote: > Beautiful one liner. I have to write an ugly hack to make it work. I > was forcing the translations because I need to translate certain > sections only. > > def b

[web2py] Re: Help rate this logo I designed.

2011-04-09 Thread b00m_chef
A little off-topic isn't this? Wouldn't you benefit more from getting feedback from http://www.reddit.com/r/graphic_design or ARS Technica? On Apr 9, 2:48 pm, Pystar wrote: > This is a logo I designed for a project of mine, I would like some > criticism about it, and what image it evokes in yo

[web2py] Re: import datetime vs from datetime import datetime

2011-04-09 Thread Anthony
On Saturday, April 9, 2011 6:37:15 PM UTC-4, niknok wrote: > > Hello. > > What is the difference between the statements: import datetime vs from > datetime import datetime > > I got stuck with my IS_DATE_IN_RANGE error " 'exceptions.AttributeError'>(type object 'datetime.datetime' has no > attri

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Anthony
On Saturday, April 9, 2011 6:40:03 PM UTC-4, 黄祥 wrote: > > actually my real intention is : > > i have the same function that repeated many times in 1 controller (repeated > to different tables), so that i would to make it simple just put it on > modules, what do you think about it? > > if i cr

[web2py] Re: T usage

2011-04-09 Thread niknok
Beautiful one liner. I have to write an ugly hack to make it work. I was forcing the translations because I need to translate certain sections only. def babel(lang, s): # forced translation of Q&A section T.force(lang) if type(s)==list: loc_string=[] for i in s:

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Jonathan Lundell
On Apr 9, 2011, at 3:40 PM, Stifan Kristi wrote: > actually my real intention is : > > i have the same function that repeated many times in 1 controller (repeated > to different tables), so that i would to make it simple just put it on > modules, what do you think about it? > > if i created th

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
actually my real intention is : i have the same function that repeated many times in 1 controller (repeated to different tables), so that i would to make it simple just put it on modules, what do you think about it? if i created the new function in 1 controller and then the other function access

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Serbitar
Next question is: How do I attach a label to a virtual field?

[web2py] import datetime vs from datetime import datetime

2011-04-09 Thread niknok
Hello. What is the difference between the statements: import datetime vs from datetime import datetime I got stuck with my IS_DATE_IN_RANGE error "(type object 'datetime.datetime' has no attribute 'timedelta')" until i added "import datetime" to the controller. All the while, I thought I already

[web2py] custom widget doesn't validate correctly

2011-04-09 Thread niknok
I got this custom widget from the list: def radio_h(field,value): nbsp = XML(' ') items=[TAG[''] (SPAN(name,INPUT(_type='radio',_value=key,_name=field.name,value=value)),nbsp,nbsp) for key,name in field.requires.options()] return DIV(*items) In my controller: define_table(

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Serbitar
Right. My problem was not the function itself, but how to generally create a dynamic virtual field with dynamic fields as computation variables (in this case from a given list). On Apr 10, 12:02 am, Anthony wrote: > To create virtual fields, you first have to define a class, such as: > > class My

Re: [web2py] Re: session.forget()

2011-04-09 Thread Stifan Kristi
thank you so much for your explaination. i'm quite understand right now. best regards, steve van christie On Sun, Apr 10, 2011 at 1:02 AM, Anthony wrote: > On Saturday, April 9, 2011 12:44:06 PM UTC-4, 黄祥 wrote: >> >> i'm understand right now, thank you very much for your detail >> explainatio

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Serbitar
Have the solution: Dynamic Fields: list = ["a","b","c","d"] fields = [] for entry in list: fields += [Field(entry, type="string")] db.define_table('test', *fields) Dynamic virtual Fields: class MyVirtualFields(object): pass for entry in list: def func(self): return getattr

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Anthony
On Saturday, April 9, 2011 7:34:25 AM UTC-4, Serbitar wrote: > > Sorry, misstyped and sent the message early. So once again: > > I can create database fields from a list like this: > > list = ["a","b","c","d"] > fields = [] > for entry in list: > fields += [Field(entry, type="string")] >

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Serbitar
Hm, that might be a last resort. I am trying to do something more in line with settatr, but unfortunately, even the fields to compute the virtual fields are variables and not strings in the function, which is also named after the virtual table instead of being a string argument. Seems quite tricky.

[web2py] Help rate this logo I designed.

2011-04-09 Thread Pystar
This is a logo I designed for a project of mine, I would like some criticism about it, and what image it evokes in your mind. I need feedback. P.S: I am/have always been a code writer, never a designer. Thanks This is the link http://aitoehigie.files.wordpress.com/2011/04/logo2.jpg?w=155&h=50

Re: [web2py] MARKMIN() not working...

2011-04-09 Thread Jason Brower
Yeah those work. After looking at what I had typed for markmin I noticed that: ** not bold** and **bold** are different. The space after the ** doesn't let it be bold. If this was intentional, I am all for it, but it could be a bug. BR, Jason Brower On 04/09/2011 09:53 PM, Bruno Rocha wrote:

[web2py] Re: why connect to remote a DB when you can ....

2011-04-09 Thread bobv
Hey Mart: I am extremely interested on your idea. This will save me time figuring it out. Please teach me how to do it on you most convenient time. Regards, Bob On Apr 9, 6:24 am, mart wrote: > Hey, > > Good morning! > > I don't know why it didn't hit me before, but finally it did... So, as >

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Jay
I use this method for generating totally dynamic forms. 1. Create an array, say out 2. Append "Field(, , )" to this array for all fields I need - note this is a string, no function calls 3. Wrap the above in an SQLFORM statement. formstring = 'SQLFORM.factory(' +','.join(out)+')' 4. Then eval th

Re: [web2py] MARKMIN() not working...

2011-04-09 Thread Bruno Rocha
Did you tested something like this? {{markmintext = """ # Testing MARKMIN - This should work **This should be bold** """}} {{=MARKMIN(markmintext)}} On Fri, Apr 8, 2011 at 2:36 PM, Jason Brower wrote: > It seems when I do the following: > {{=MARKMIN(page.content)}} It ignores it and simply

[web2py] MARKMIN() not working...

2011-04-09 Thread Jason Brower
On 04/08/2011 08:36 PM, Jason Brower wrote: It seems when I do the following: {{=MARKMIN(page.content)}} It ignores it and simply prints the text. Is there something I am doing wrong? Best Regards, Jason Brower Bump... this problem may be a bug in the system and wanted to see if anyone else

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread pbreit
The one project I've seen that is sort of designed how you are suggesting is InstantPress: http://code.google.com/p/instant-press/ But I agree with Anthony, I always encourage keeping it simple. There's a saying about premature optimization and it's not good.

Re: [web2py] Re: session.forget()

2011-04-09 Thread Anthony
On Saturday, April 9, 2011 12:44:06 PM UTC-4, 黄祥 wrote: > > i'm understand right now, thank you very much for your detail > explaination. > what is the different within session.forget(response) and session.forget()? > session.forget() just tells web2py not to bother saving the current session

[web2py] Re: please help: owned by "windows way of doing things"

2011-04-09 Thread Anthony
I think in Linux, line breaks are just a single \n character, but in windows, it's supposed to be \r\n. You might need to replace all \n's with \r\n's. On Saturday, April 9, 2011 1:15:55 PM UTC-4, w2padawan wrote: > hello everybody, > > sorry if this a too basic question, but have not found

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Anthony
You wouldn't generally want to define your DAL connection or crud in your module -- instead, you would likely want to define them in your models and then pass them to your module function as arguments. I think you would do something like: def manage(request, db, crud, title, table) and then

[web2py] Re: LAMP like frameworks are dying. Time for the javascript age

2011-04-09 Thread pbreit
I tend to agree that LAMP will thrive for quite some time. But node.js and the article are interesting. The one thing I have witnessed with good success is returning tabular data as JSON and then using JavaScript to render the . We used YUI for this with good results. We could easily return tho

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread pbreit
If you're new (or not) to Python or Web2py, I would suggest: First: put the functions in the controllers that call them Second: put the function in "models" if multiple controllers need to call it Third: local_import() from "modules" if it doesn't need access to the web2py environment (pass in "r

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
i've tried to run what you suggested, but still have a problem: On Modules: #!/usr/bin/env python # coding: utf8 from gluon.html import * from gluon.http import * from gluon.validators import * from gluon.sqlhtml import * # request, response, session, cache, T, db(s) # must be passed and cannot be

[web2py] please help: owned by "windows way of doing things"

2011-04-09 Thread danto
hello everybody, sorry if this a too basic question, but have not found anything about how to solve this. I'm trying to print some text to a serial printer directly from my controller just pushing the text to /dev/ttyS0 with Popen. that works in gnulinux but in win32 it doesn't work if the text ha

Re: [web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Stifan Kristi
thank you so much for your explaination, i've already read that url, honestly i'm the newbie in python and web2py, could you please give an example how to pass the global objects to the function as arguments? i've already test for the simple thing, it work, but for global objects i'm still confused

Re: [web2py] Re: session.forget()

2011-04-09 Thread Stifan Kristi
i'm understand right now, thank you very much for your detail explaination. what is the different within session.forget(response) and session.forget()? 1 more things, it is best practice to save the session in database? like i read in http://web2py.com/book/default/chapter/11#Sessions-in-Database i

[web2py] Re: LAMP like frameworks are dying. Time for the javascript age

2011-04-09 Thread VP
I think the author is still in the honeymoon with his newly found love: Node.js. After the honeymoon, he will realize that the LAMP stack is not only dead, it'll be around and kicking for a long time to come. The same is uncertain for "javascript frameworks", which will find their places nonethe

[web2py] Re: Error trying to use PolyModel

2011-04-09 Thread RipRyness
Could this be a bug in dal.py? Does 'polymodel' need to be in this list? ... def define_table( ... for key in args: if key not in [ 'migrate', 'primarykey', 'fake_migrate', 'format',

[web2py] A complex validator problem

2011-04-09 Thread guruyaya
Take this example db.define_table('table1', Field('title)); db.define_table('table2',Field('title'),Field('table1_id',db.table1)) db.define_table('table3',Field('title'),Field('table2_id',db.table2,'another_table2_id',db.table2)); Now I want to write a validator that makes sure Both table2 and ano

[web2py] Janrain rpx and jquery mobile multi page, single html file

2011-04-09 Thread ChrisM
Hi i'm trying to include janrain into a jquery mobile enabled site, using web2py running on app engine. I am using single html file with multple jquery mobile pages which Are elements accessed via www.domain_name.com#home, #login etc #login contains the jainrain iframe widget (embed=true) I keep

[web2py] Re: Quick Admin Suggestion

2011-04-09 Thread ra3don
Oh, I see. I missed the links at the top when editing default.py that take you to the various pages. Thanks! On Apr 8, 8:46 pm, Anthony wrote: > If you're on the "site" page that lists all the applications, clicking an > application name takes you to the /default/index page for the app. If you're

[web2py] Re: how to define functions in modules and then import it

2011-04-09 Thread Anthony
See http://web2py.com/book/default/chapter/04#Third-Party-Modules. Note, if your function needs to refer to some of the web2py global objects (as yours does), then you will need to explicitly pass them to the function as arguments (external modules cannot "see" web2py globals). On Saturday, Ap

[web2py] Re: session.forget()

2011-04-09 Thread Anthony
I think there was a recent change in web2py whereby the session is no longer saved if it has not been changed, and because session.forget() merely prevents saving, I'm not sure it would be useful to you (unless you do actually change the session but then for some reason do not want to save it).

[web2py] epydoc behavior

2011-04-09 Thread Ed Greenberg
Hi Folks, Not really a web2py question, but it affects me daily. When running the epydoc web pages at http://web2py.com/examples/static/epydoc/frames.html, I get odd behavior, and I wonder if it's just me, or if everybody sees this: Whenever I hit "source code" for a function, the large frame l

[web2py] Re: Dynamic virtual fields

2011-04-09 Thread Serbitar
Sorry, misstyped and sent the message early. So once again: I can create database fields from a list like this: list = ["a","b","c","d"] fields = [] for entry in list: fields += [Field(entry, type="string")] db.define_table('test', *fields) Now I want to have a virtual field for each field i

[web2py] Dynamic virtual fields

2011-04-09 Thread Serbitar
I can create Datbase fields from a list like this: list = [a,b,c,d] fields = [] for entry in list:

[web2py] Re: Running web2py source on Mac

2011-04-09 Thread Christopher Steel
Look at the bright side, now you can create distributable OS X web2py.app by renaming your web2py application to init and creating an OS X dmg with your web2py.app ; ) Now I like use hg to grab Web2py because it gives you the option to grab a specific version and it is easy to automate installat

[web2py] why connect to remote a DB when you can ....

2011-04-09 Thread mart
Hey, Good morning! I don't know why it didn't hit me before, but finally it did... So, as some of you may remember, I spent a good amont of time trying to work out a good solution to get scripts that use DAL stand-alone to connect to remote a SQLite DB running behind web2py. At best, I have had l

[web2py] [Discuss] LAMP like frameworks are dying. Time for the javascript age

2011-04-09 Thread Luther Goh Lu Feng
I got this link off twitter, and would like to share this article with the community as I felt that it is a good read for web developers. http://metamarketsgroup.com/blog/node-js-and-the-javascript-age/ "Three months ago, we decided to tear down the framework we were using for our dashboard, Pyth

[web2py] how to define functions in modules and then import it

2011-04-09 Thread 黄祥
hi, i read in http://web2py.com/book/default/chapter/11#Efficiency-and-Scalability it said : define functions in modules, import them and use those functions as needed. does anyone know how to define functions in modules and then import it? e.g. def manage(): table = db.blog form = crud.u

[web2py] session.forget()

2011-04-09 Thread 黄祥
hi, i want to follow the suggestion on web2py books http://web2py.com/book/default/chapter/11#Efficiency-and-Scalability : Set session.forget() in all controllers and/or functions that do not change the session. is it means that every controller i must use : def call(): session.forget() r