[TurboGears] Showing symbol like thru XML() in kid

2007-07-16 Thread tml

Hi,

I have a string in my db like Mike  Ike, and am trying to show it
in my kid with:

${XML(myobj.str)}

But, i'm getting this error:

  File /usr/lib/python2.5/site-packages/kid-0.9.5-py2.5.egg/kid/
parser.py, line 432, in feed
raise expat.ExpatError(e)
ExpatError: Error parsing XML:
xmlMike  Ike  said
  ^
not well-formed (invalid token): line 1, column 7
Error in code generated from template file

I thought XML() was supposed to escape such characters to show up
properly? Can someone suggest a better way to do this?

TIA!

-tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Selectively applying kid templates

2007-07-14 Thread tml

Hi,

I'm wondering if anyone knows how to apply kid templates to a class
selectively.

I have a piece of code like this in my controllers.py:

blogs = news = MessagePost()

So, as you can see, http://localhost/blogs and http://localhost/news
apply to the same object.

I wanted this because the code base is the same for both. But, i'm not
sure how to make the kid templates choosable based on where the url
request came from.

Is there anyway i can use @template in such a way?

thanks!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Generator error, why? how bad is it?

2007-06-09 Thread tml

Hello,

I am getting this weird issue when ever i try to load a page other
than my homepagel.. and then click on the hopepage link. It doesn't
seem to cause any issues in terms of loading/working of the site
itself, but it does show up on the logs. Can somone please explain why
this might be happening?

TIA!

Here is my system spec (python 2.5, ubuntu 7.04, SQLAlchemy 0.3.8):

* TurboGears 1.0.2.2
* Cheetah 2.0rc8
* configobj 4.4.0
* DecoratorTools 1.4
* RuleDispatch 0.5a0.dev-r2306
* setuptools 0.6c5
* FormEncode 0.7.1
* PasteScript 1.3.4
* elementtree 1.2.6-20050316
* simplejson 1.7.1
* CherryPy 2.2.1
* TurboKid 1.0.1
* TurboCheetah 0.9.5
* TurboJson 1.0
* PyProtocols 1.0a0dev-r2302
* PasteDeploy 1.3
* Paste 1.3
* kid 0.9.5
* Cheetah 2.0rc8
* RuleDispatch 0.5a0.dev-r2306
* DecoratorTools 1.4

Identity Providers

* sqlobject (TurboGears 1.0.2.2)
* sqlalchemy (TurboGears 1.0.2.2)

tg-admin Commands

* info (TurboGears 1.0.2.2)
* shell (TurboGears 1.0.2.2)
* quickstart (TurboGears 1.0.2.2)
* update (TurboGears 1.0.2.2)
* sql (TurboGears 1.0.2.2)
* i18n (TurboGears 1.0.2.2)
* toolbox (TurboGears 1.0.2.2)

Visit Managers

* sqlobject (TurboGears 1.0.2.2)
* sqlalchemy (TurboGears 1.0.2.2)

Template Engines

* kid (TurboKid 1.0.1)
* cheetah (TurboCheetah 0.9.5)
* json (TurboJson 1.0)

Widget Packages

* tinymce (TurboTinyMCE 1.0.6)
* submodal (submodal 1.5)

Toolbox Plugins

* info (TurboGears 1.0.2.2)
* catwalk (TurboGears 1.0.2.2)
* shell (TurboGears 1.0.2.2)
* designer (TurboGears 1.0.2.2)
* widgets (TurboGears 1.0.2.2)
* admi18n (TurboGears 1.0.2.2)

TurboGears Extensions

* visit (TurboGears 1.0.2.2)
* identity (TurboGears 1.0.2.2)

Errors:

127.0.0.1 - armod GET / HTTP/1.1 200 3862 http://localhost:8080/
inbox/alert Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4)
Gecko/20070602 Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET /tg_widgets/jslibs/javascript/MochiKit.js HTTP/
1.1 200 172604 http://localhost:8080/; Mozilla/5.0 (X11; U; Linux
i686; en-US; rv:1.8.1.4) Gecko/20070602 Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET /tg_widgets/submodal/css/subModal.css HTTP/1.1
200 1032 http://localhost:8080/; Mozilla/5.0 (X11; U; Linux i686; en-
US; rv:1.8.1.4) Gecko/20070602 Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET /tg_widgets/submodal/javascript/subModal.js
HTTP/1.1 200 6518 http://localhost:8080/; Mozilla/5.0 (X11; U;
Linux i686; en-US; rv:1.8.1.4) Gecko/20070602 Firefox/2.0.0.4
(Swiftfox)
127.0.0.1 - armod GET /static/css/main.css HTTP/1.1 200 31207
http://localhost:8080/; Mozilla/5.0 (X11; U; Linux i686; en-US; rv:
1.8.1.4) Gecko/20070602 Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET /static/javascript/builds/main.js HTTP/1.1 200
16364 http://localhost:8080/; Mozilla/5.0 (X11; U; Linux i686; en-
US; rv:1.8.1.4) Gecko/20070602 Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET /tg_widgets/submodal/html/loading.html HTTP/
1.1 200 539 http://localhost:8080/; Mozilla/5.0 (X11; U; Linux
i686; en-US; rv:1.8.1.4) Gecko/20070602 Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET /tg_widgets/submodal/css/style.css HTTP/1.1
200 213 http://localhost:8080/tg_widgets/submodal/html/loading.html;
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20070602
Firefox/2.0.0.4 (Swiftfox)
127.0.0.1 - armod GET / HTTP/1.1 200 3862 http://localhost:8080/;
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20070602
Firefox/2.0.0.4 (Swiftfox)
2007-06-09 08:25:01,954 cherrypy.msg INFO : Traceback (most recent
call last):
  File /usr/lib/python2.5/site-packages/CherryPy-2.2.1-py2.5.egg/
cherrypy/_cpwsgi.py, line 97, in wsgiApp
yield chunk
GeneratorExit

Exception exceptions.RuntimeError: 'generator ignored GeneratorExit'
in generator object at 0x9216e6c ignored


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] how to disable page caching in some cases?

2007-05-08 Thread tml

I dont see this problem on my local dev machine, but when I'm running
on my server, if i login, the next page whcih comes up still thinks
I'm not logged in.

I use redirect('') in TG after a succesful login. The issues goes away
when i refresh with CTRL+R.

The server is setup with apache on frontend using rewrite/mod_proxy to
forward to TG.

Anyone know how to fix this issue?

Also, I use a bunch of widgets, like submodal, mochikit, etc. and this
causes 5-6 file loads like css, js, html pages associated with each
page. This is giving the perception of a slowdown on my browser side
as the request hits my server and it replies with 200 OK. How can I
optimize this performance?

thanks.

-tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] redirect without clearing a form

2007-04-27 Thread tml

Hi,

I have a form validator setup like:

class NewPost(widgets.WidgetsList):
   topic = widgets.TextField('topic', label=_(Title:),
attrs=dict(maxlength='255'))
   tags = widgets.TextField('tags', label=_(Tags), default=e.g.
upgrade, PC, HDD, attrs=dict(maxlength='255'))
   content = TinyMCE(name=content, rows=25, cols=80,
mce_options=mce_options, field_class=editPostContent)

class PostSchema(validators.Schema):
   topic = validators.UnicodeString(not_empty=True)
   tags  = validators.UnicodeString(not_empty=True)
   content = validators.UnicodeString(not_empty=True)

class NewPostForm(widgets.TableForm):
   template = 'se.templates.post.new'
   fields = NewPost()
   validator = PostSchema()


new_post = NewPostForm()

def new(..):
 ...
 return dict(form=new_post, action='/save?id='+self.id)

def edit(..):
 ...
 return dict(form=new_post, action='/save?id='+self.id)

@expose()
@validate(form=new_post)
@error_handler()
def save(...args...):
   ...

Now in above code, save() is called from both new and edit. But, if
the validator fails, i want it to go back to the page it came from
(eithr new or edit). How do i do this?? If i use redirect() inside
save(), then the arguments which were given in the pages' post are all
cleared!

Can someone tell me how i can use validators the right way in this
situation?

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] subdomains rewriting with apache/TG

2007-04-26 Thread tml

Hi,

I have the following rewrite rules in apache.conf to rewrite urls
which dont have have static or error in their path to TG which is
running localhost:8080. This works very well:

IfModule mod_rewrite.c
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(static|error)
RewriteRule ^(.*)$ http://localhost:8080$1 [P,L]
ProxyPassReverse / http://localhost:8080/
/IfModule

However, now i'm trying to do something like this:

someuser.domain.com should be redirected to http://localhost:8080/user/userid

Does anyone know how to write such a rewrite rule which doesn't break
the above setup?

TIA.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: converting url into kw dict like cherrypy does

2007-04-07 Thread tml

Hi,

Thanks for the replise. I tried the function given and also
cgi.parse_qs. Unfortunatley it only works partially. The expected
behaviour like the way turbogear sees it is not the same. I realized i
dont need args parsing, just kw is fine. But both above args dont do
it fully like TG does.

For example for a query like:
a=1b=2c.0.1=3c.0.2=4c.1.1=5c.1.2=6d.0=arg1d.0=arg2

Turbogears gets this kw argument as:

kw =
{'a': '1',
 'b': '2',
 'c': {'1': {'1': '5', '2': '6'}, '0': {'1': '3', '2': '4'}},
 'd': {'0': ['arg1', 'arg2']}}

This is what i would like to decode my string into, so i can pass this
argument to the widget.render. Does anyone know how to achieve this
with fully feature? note how the multiple nested dicts and arrays
work. This isn't simply about parsing a=1b=2, etc... The above
structure is very nice and organized so i can specify a range of
parameters to my apps.

thanks.

-tml


On Apr 4, 8:24 am, fumanchu [EMAIL PROTECTED] wrote:
 tml wrote:
  Anyone know how I can take a url like this:

 http://domain/loc/widget?id=1j.0.0=tomj.0.1=jerryk=hellof.0=woof...

  and convert that into a (arg, kw) pair like cherrypy does when calling
  the corresponding controller argument?

  I'm trying to render the widget internally based on the url keywords,
  so I would like to call a the widget's function, but I can't pass it
  the url string as is.

 The **kwargs part is easy (even easier if you don't care about image
 maps):

 image_map_pattern = re.compile(r[0-9]+,[0-9]+)

 def parse_query_string(query_string, keep_blank_values=True):
 Build a params dictionary from a query_string.
 if image_map_pattern.match(query_string):
 # Server-side image map. Map the coords to 'x' and 'y'
 # (like CGI::Request does).
 pm = query_string.split(,)
 pm = {'x': int(pm[0]), 'y': int(pm[1])}
 else:
 pm = cgi.parse_qs(query_string, keep_blank_values)
 for key, val in pm.items():
 if len(val) == 1:
 pm[key] = val[0]
 return pm

 The *args part is very nasty and depends on the arrangement of your
 controllers. But you might be able to use mapPathToObject (CP 2.1; for
 CP 2.2 use cherrypy.request.mapPathToObject) to find which exposed
 callable will be used.

 Robert Brewer
 System Architect
 Amor Ministries
 [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] how to enable rss icon in firefox?

2007-04-04 Thread tml

Hi,

If you goto http://groups.google.com/group/turbogears

you will notice in firefox, there is a little RSS icon to the right on
the adddress bar. I was able to get feeds working on my site with the
FeedController tutorial.

In my main controller I have a:

feed = MyFeedClass()

so, i can acess the feeds with http://domain/feed/atom1.0

But, I dont see that little icon anywhere. I would like to make such
an icon available on all pages on my site. Anyone know how to do
this??

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] converting url into kw dict like cherrypy does

2007-04-04 Thread tml

Hello,

Anyone know how I can take a url like this:

http://domain/loc/widget?id=1j.0.0=tomj.0.1=jerryk=hellof.0=woof.o=hoo

and convert that into a (arg, kw) pair like cherrypy does when calling
the corresponding controller argument?

I'm trying to render the widget internally based on the url keywords,
so I would like to call a the widget's function, but I can't pass it
the url string as is.

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] url encoding in kid

2007-04-01 Thread tml

Hey,

I have this code in kid:

a href=/search?tag=${someTag}${someTag}/a

However, this confuses cherrypy if I the someTag = Tom  Jerry. The
'' makes the function Tom and Jerry has two seperate arguments.

I tried this:
a href=/search?tag=${tg.url(someTag)}${someTag}/a

But, that didn't fix anything either.

Anyone know how I can encode the tag into url safe format from kid? I
could use urlencode, but then i'll need python blocks to import it i
think, so would not be a great way.

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: url encoding in kid

2007-04-01 Thread tml

Hi, thanks guys.

Now i used tg.url(myurl, tag=someTag) and that worked great!!

Chris, can you explain why quote_plus is better than tg.url? Is there
some particular reason you say i must use it?

thanks.

On Apr 1, 4:50 am, Christoph Zwerschke [EMAIL PROTECTED] wrote:
 tml wrote:

   I tried this:
   a href=/search?tag=${tg.url(someTag)}${someTag}/a
  
   But, that didn't fix anything either.

 You must use tg.quote_plus instead of tg.url.

 -- Chris


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: embedding kid code into a template

2007-03-31 Thread tml



On Mar 31, 7:15 am, Christoph Zwerschke [EMAIL PROTECTED] wrote:
 tml wrote:
  I have a form input where users can insert BBcode type custom tags. In
  one of them, I would like to insert a special tag which embeds my own
  widget like a calender.

  So, in the form, if user has [Calender], i want the calender to show
  up in that part of the html.

  How can I insert the calender widget's code in this situation?
  Currently, I have the data stored into the db, and then read back and
  displayed on the page. So, no pre- or post- processing exists. But i'm
  sure i will need one (or both) of them? I wanted to get your input.

 Somewhere, you must convert your BBcode to HTML. If the BBcode processor
 is extendable, try to supplement it with knowledge of your tag,
 otherwise do it directly after you called the BBcode processor.

 -- Chris

Yes, But how do i insert a widget? Because the myDBtable.htmlcode
variable is passed directly into XML() which will not parse something
like ${widget.show(...)}. Thats what I wanted to know, if kid can be
made aware enough to do that.

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] How to setup separate admin user for 'sql create'?

2007-03-17 Thread tml

Hey,

I have  in my dev.cfg:

sqlalchemy.dburi=mysql://mywebuser:[EMAIL PROTECTED]:3306/myDB

However, this mywebuser doesn't have privileges like create and drop
which are used by 'tg-admin sql create'.

Is there a way to specify an admin account only for sql create ? I
dont want to keep editing the file by hand, and dont want to run the
webapp with admin user either.

thank you.
- tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: Duplicate log messages from SA

2007-03-17 Thread tml

someone can please take a look and help me? I can't find any
documentation from google searching for logging sqlalchemy turbogears,
except the metadata.engine.echo method which is printing two messages
at a time.

I want to be atleast able to change logging from tg-admin shell, when
i do some sample tests with my controllers.

-tml

On Mar 16, 12:03 pm, tml [EMAIL PROTECTED] wrote:
 Hey Jorge,

 Can you explain a bit more on how I can do that? I searched forloggingand 
 found this in my dev.cfg:

 [logging]
 [[loggers]]
 [[[daFinci]]]
 level='DEBUG'
 qualname='tgWeb'
 handlers=['debug_out']

 [[[allinfo]]]
 level='INFO'
 handlers=['debug_out']

 [[[access]]]
 level='INFO'
 qualname='turbogears.access'
 handlers=['access_out']
 propagate=0

 Are you saying I need to change something in the above? I am seeing
 the logs in tg-shell. I followed thesqlalchemytutorial and set
 metadata.engine.echo = True just like they say. Can you please specify
 what exactly i need to do to lowerlogginglevel ?

 thanks.

 -tml

 On Mar 16, 8:48 am, Jorge Vargas [EMAIL PROTECTED] wrote:

  On 3/14/07, tml [EMAIL PROTECTED] wrote:

   Hey,

   I do a tg-admin shell and when i set metadata.engine.echo = True, it
   always prints the sql log twice. Is this expected? It uses ipython
   shell.

  yes yout using the old structure, SA now works with common python
 loggingso that should be off, and you should lower thelogginglevel.

   thanks.
   -tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: Is there a 1.1 release for TG in the next few months?

2007-03-16 Thread tml



On Mar 15, 8:17 pm, Mark Ramm [EMAIL PROTECTED] wrote:
 On 3/15/07, Noah Gift [EMAIL PROTECTED] wrote:



  If I was to use Genshi/sqlalchemy in 1.0 does this seem compatible for
  a move to python2.5 and tg1.1?

 Certianly.   Genshi and SQLAlchemy will continue to be supported as
 they are now, but probably will not become the defaults in TG 1.1.

 And they should both work with Python 2.5 right now.   In fact
 everything should work on 2.5 now in the 1.0 branch.  The only thing
 is you need to compile RuleDispatch if you aren't on Windows (we've
 posted a windows binary, because  our poor windows brothers and
 sisters don't often have compilers...).

Hi Mark, Sorry, but i dont know what RuleDispatch is or if its used by
TG internally. I dont ever use anything like that in my code, so I
don't need to compile it right?

thanks for answering.

-tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: Duplicate log messages from SA

2007-03-16 Thread tml

Hey Jorge,

Can you explain a bit more on how I can do that? I searched for
logging and found this in my dev.cfg:

[logging]
[[loggers]]
[[[daFinci]]]
level='DEBUG'
qualname='tgWeb'
handlers=['debug_out']

[[[allinfo]]]
level='INFO'
handlers=['debug_out']

[[[access]]]
level='INFO'
qualname='turbogears.access'
handlers=['access_out']
propagate=0

Are you saying I need to change something in the above? I am seeing
the logs in tg-shell. I followed the sqlalchemy tutorial and set
metadata.engine.echo = True just like they say. Can you please specify
what exactly i need to do to lower logging level ?

thanks.

-tml

On Mar 16, 8:48 am, Jorge Vargas [EMAIL PROTECTED] wrote:
 On 3/14/07, tml [EMAIL PROTECTED] wrote:

  Hey,

  I do a tg-admin shell and when i set metadata.engine.echo = True, it
  always prints the sql log twice. Is this expected? It uses ipython
  shell.

 yes yout using the old structure, SA now works with common python
 logging so that should be off, and you should lower the logging level.

  thanks.
  -tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: incrementing in visitor counter

2007-03-15 Thread tml

Hello guys,

I tried what Andy suggested and its not working. Basically had two
shells:

In [1]: u = User.get(1)
In [2]: u
Out[2]: tgWeb.model.User object at 0xb725f40c
In [3]: u.visit_counter += 1
In [4]: u.flush()

I did the above. u.flush() was done at the end in both the shells.
Final value of visit_counter is 1 (initial value is 0).

I'll check on alberto's suggestion.

thanks,
-tml

On Mar 15, 5:04 am, Alberto Valverde [EMAIL PROTECTED] wrote:
 On Mar 15, 2007, at 1:08 AM, Andrew Grover wrote:





  On 3/14/07, tml [EMAIL PROTECTED] wrote:
  I'm using SA and have a visit counter for user profiles and some
  other
  pages. I have a visit_counter column in User object, and usually do
  User.get(id).visit_counter+=1

  But I realize this is a race if all the threads are serving the same
  page. Can someone tell how to do this right?

  If your database implements ACID features (pretty much all?) then it
  will ensure that the race is prevented.

  You can test this by opening two tg shells -- you will see that if
  they both access the same row, the second one will freeze until the
  first one's transaction ends.

 I don't think that it would turn out this way unless some sort of
 SELECT FOR UPDATE statement is issued by the orm. The possibility
 exists of two threads reading 5, in differerent transactions, and
 commiting back 6, effectively counting only one visitor. Or maybe
 throwing a non-serializable update error (if using postgres).

 The table should be locked from concurrent updates when the value is
 read, something like:

 table.select(table.c.id==id, for_update=True)

 I'm not sure if you can do it with a mapper, better ask in the SA list.

 Alberto


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: incrementing in visitor counter

2007-03-15 Thread tml

Hello guys,

I tried what Andy suggested and its not working. Basically had two
shells:

In [1]: u = User.get(1)
In [2]: u
Out[2]: tgWeb.model.User object at 0xb725f40c
In [3]: u.visit_counter += 1
In [4]: u.flush()

I did the above. u.flush() was done at the end in both the shells.
Final value of visit_counter is 1 (initial value is 0).

I'll check on alberto's suggestion.

thanks,
-tml

On Mar 15, 5:04 am, Alberto Valverde [EMAIL PROTECTED] wrote:
 On Mar 15, 2007, at 1:08 AM, Andrew Grover wrote:





  On 3/14/07, tml [EMAIL PROTECTED] wrote:
  I'm using SA and have a visit counter for user profiles and some
  other
  pages. I have a visit_counter column in User object, and usually do
  User.get(id).visit_counter+=1

  But I realize this is a race if all the threads are serving the same
  page. Can someone tell how to do this right?

  If your database implements ACID features (pretty much all?) then it
  will ensure that the race is prevented.

  You can test this by opening two tg shells -- you will see that if
  they both access the same row, the second one will freeze until the
  first one's transaction ends.

 I don't think that it would turn out this way unless some sort of
 SELECT FOR UPDATE statement is issued by the orm. The possibility
 exists of two threads reading 5, in differerent transactions, and
 commiting back 6, effectively counting only one visitor. Or maybe
 throwing a non-serializable update error (if using postgres).

 The table should be locked from concurrent updates when the value is
 read, something like:

 table.select(table.c.id==id, for_update=True)

 I'm not sure if you can do it with a mapper, better ask in the SA list.

 Alberto


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Duplicate log messages from SA

2007-03-14 Thread tml

Hey,

I do a tg-admin shell and when i set metadata.engine.echo = True, it
always prints the sql log twice. Is this expected? It uses ipython
shell.

thanks.
-tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] incrementing in visitor counter

2007-03-14 Thread tml

Hi,

I'm using SA and have a visit counter for user profiles and some other
pages. I have a visit_counter column in User object, and usually do
User.get(id).visit_counter+=1

But I realize this is a race if all the threads are serving the same
page. Can someone tell how to do this right?

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] TG and microapps

2007-03-10 Thread tml

Hi,

I read an earlier discussion on how to do proxy calls in microapps or
to just do local controller based calls.

I want to do tagging for my site,and I found Tasty 1.1 on cogbin
which seems to do this. Does anyone use this? Any recommendations if
this is a good place for me to start for implementing tags? Or any
other recommendations?

I'm wondering if you guys have any code to do calls to Tasty
controller locally instead of running it as a service which seems
wasteful. It seems like you need to write your own controller, but
would be nice if someone had sharable code for this.

thanks!

-tml


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: ANNOUNCE: Select-Shuttle 1.1

2007-03-08 Thread tml

Hi!

Thanks for this :)

Is there a demo I can try out? I looked at the site URL, which is in
spanish I think, so couldn't figure where to navigate.

thanks.

Tml

On Mar 8, 3:27 pm, Jorge Godoy [EMAIL PROTECTED] wrote:
 Hi!

 I've made a new release of SelectShuttle with a few improvements:

  - All parameters are documented at the toolbox

  - I've added a CSS stylesheet to format it and make it easier to override
my default layout for whoever wants a different look

  - I've added an option to show a hyperlink below the select shuttle to
allow, for example, creating add a new option links.  A target and an
image can be provided as well.

 It is 100% backwards compatible with the previous release.

 It's available athttp://python.org/pypi/Select-Shuttle/1.1

 Changes are all visible 
 athttp://public-trac.godoy.homeip.net/trac/selectshuttle/changeset/28

 Enjoy! :-)

 --
 Jorge Godoy  [EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Doing transactions with SA + TG

2007-03-01 Thread tml

Hey,

I have this code which works fine in tg-shell. But, it doesn't work in
the controller context. I can't get the primary key of the row which
was inserted from .id , but I can from the shell.

Anyone know whats going on with turbogears?

transaction = session.create_transaction()
try:
  a = SomeTable(1,2,3)
  session.save(a)
 do some stuff which could fail
  transaction.commit()
  print a.id   #  This is None at this point! but in the shell
you get the right value of the primary key of the inserted row
  # How to get primary key of the item which was just saved?
except:
  transaction.rollback()
  raise


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: Doing transactions with SA + TG

2007-03-01 Thread tml

Note, that the 'print a.id' still doesn't work even after commit, so I
can't know the id (primary key) of the row I inserted unfortunately.

However, I figured why trnasactions weren't working. I was using
MyISAM backed tables which dont support transactions on mysql.
Changing to InnoDB did make that work, however the above problem still
exists unfortunately. Anyone know how to get the primary key id?

thanks.

On Mar 1, 2:31 am, tml [EMAIL PROTECTED] wrote:
 Hey,

 I have this code which works fine in tg-shell. But, it doesn't work in
 the controller context. I can't get the primary key of the row which
 was inserted from .id , but I can from the shell.

 Anyone know whats going on with turbogears?

 transaction = session.create_transaction()
 try:
   a = SomeTable(1,2,3)
   session.save(a)
  do some stuff which could fail
   transaction.commit()
   print a.id   #  This is None at this point! but in the shell
 you get the right value of the primary key of the inserted row
   # How to get primary key of the item which was just saved?
 except:
   transaction.rollback()
   raise


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] Re: Doing transactions with SA + TG

2007-03-01 Thread tml

On further investigation, I answers my questions and solved the
problem! lol

I realized turbogears does the whole controller in a single
transaction. This is quite useful! I dont have to worry about
transactions at all this way.

My code now looks like:

def func():
  try:
a = SomeTable(1,2,3)
session.save(a)
.. do stuff...
session.flush()
.. do stuff with a.id, which is available now 
   except:
 session.clear()
 raise  # XXX


However, now I have another question. If i never raised the error all
the way out of the controller, how do I rollback that session.save()'s
writes? i.e. if I removed the raise marked 'XXX', and did more
processing below that line. How to rollback sesion.flush()'s writes?

thanks.

  try:
a = SomeTable(1,2,3)
session.save(a)
   do some stuff which could fail
transaction.commit()
print a.id   #  This is None at this point! but in the shell
  you get the right value of the primary key of the inserted row
# How to get primary key of the item which was just saved?
  except:
transaction.rollback()
raise


On Mar 1, 2:53 am, tml [EMAIL PROTECTED] wrote:
 Note, that the 'print a.id' still doesn't work even after commit, so I
 can't know the id (primary key) of the row I inserted unfortunately.

 However, I figured why trnasactions weren't working. I was using
 MyISAM backed tables which dont support transactions on mysql.
 Changing to InnoDB did make that work, however the above problem still
 exists unfortunately. Anyone know how to get the primary key id?

 thanks.

 On Mar 1, 2:31 am, tml [EMAIL PROTECTED] wrote:

  Hey,

  I have this code which works fine in tg-shell. But, it doesn't work in
  the controller context. I can't get the primary key of the row which
  was inserted from .id , but I can from the shell.

  Anyone know whats going on with turbogears?

  transaction = session.create_transaction()
  try:
a = SomeTable(1,2,3)
session.save(a)
   do some stuff which could fail
transaction.commit()
print a.id   #  This is None at this point! but in the shell
  you get the right value of the primary key of the inserted row
# How to get primary key of the item which was just saved?
  except:
transaction.rollback()
raise


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] cursor passing into kid

2007-02-27 Thread tml

Hey,

I'm curious what the best practice is for passing data fetched from db
into a kid template.

I'm doing a fetchall() on the resultset gotten from a SA select, and
passing the resulting python list to kid to iterate and display items.
Would the better and efficient way be to just send the result set into
kid and ask it to iterate over fetchone() ?

thanks.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~--~~~~--~~--~--~---



[TurboGears] tg.include_widgets in projname/config/app.cfg

2006-07-17 Thread TML

Looking in projname/config/app.cfg, we can see this block:

# List of Widgets to include on every page.
# for exemple ['turbogears.mochikit']
# tg.include_widgets = ['turbogears.mochikit']


If the line here is uncommented, a lot of things break. Most notably, a
lot of the widgets fail to render giving:

NoApplicableMethods: ((JSLink(name='js/MochiKit.js'),), {})

For the time being, I've gone back to using
tg.mochikit_all = True


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
TurboGears group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~--~~~~--~~--~--~---



[TurboGears] [PATCH] Catwalk and Unicode

2006-01-19 Thread TML

I've submitted a patch to
http://trac.turbogears.org/turbogears/ticket/178 that should fix the
two seperate issues:

1) When you use catwalk to edit the contents of a UncodeCol, the
previous value is not populated.
2) When you try to set a UnicodeCol as the label for a ForeignKey, you
get an exception (UnicodeEncodeError: 'ascii' codec can't encode
character)



[TurboGears] Re: Deployment on a production webserver

2006-01-19 Thread TML

http://www.cherrypy.org/wiki/VirtualPathFilter



[TurboGears] Re: patches and testing

2006-01-19 Thread TML

Can you give some additional guidance on how to view and execute the
current unit tests? I haven't been able to find any documentation on
this. (In fact, I wasn't even aware you had chosen a unit test
framework, thought that was still up in the air).



[TurboGears] Re: patches and testing

2006-01-19 Thread TML

15:10:51 [ [EMAIL PROTECTED] ] ~/src/turbogears 1507--nosetests
-bash: nosetests: command not found
15:42:34 [ [EMAIL PROTECTED] ] ~/src/turbogears 1508--svn info
Path: .
URL: http://www.turbogears.org/svn/turbogears/trunk
Repository UUID: 77541ad4-5f01-0410-9ede-a1b63cd9a898
Revision: 535
Node Kind: directory
Schedule: normal
Last Changed Author: kevin
Last Changed Rev: 535
Last Changed Date: 2006-01-18 20:19:49 -0700 (Wed, 18 Jan 2006)
Properties Last Updated: 2006-01-18 11:31:03 -0700 (Wed, 18 Jan 2006)



Not quite sure what I'm doing wrong.



[TurboGears] Re: patches and testing

2006-01-19 Thread TML

Ah! That did it. Thanks.



[TurboGears] Re: Deployment on a production webserver

2006-01-19 Thread TML

The part of the link I meant you to focus on is the one that talks
about how it works with CherryPy 2.2 (which is what TG svn currently
requires)



[TurboGears] [PATCH] tg-admin toolbox: Open browser AND start server

2005-11-24 Thread TML

Currently, I have to start toolbox with -n, because the server doesn't
start if I let toolbox open the browser. Linked below[1] is a patch
that should make this work more cleanly.

[1] http://joeysmith.com/tg-tb.patch



[TurboGears] catwalk and managing joins

2005-11-21 Thread TML

On my machines, catwalk is not able to manage joins. Clicking the
save button didn't appear to have any effect.

After some digging, I found that applying the patch[1] linked at the
bottom of this message fixed the problem.

My question to the list is two-fold:

1) Am I the only one seeing this problem?
2) Would this be the correct python idiom for solving this? [I'm not
really confident in my python idioms yet. :) ]

[1] http://www.joeysmith.com/tg.patch



[TurboGears] turbogears.org still shows 0.8a3 as current

2005-11-17 Thread TML

The topic in #turbogears suggests that 0.8a4 is available, but it's not
currently installable using ez_setup.py.