Re: [Trac] Wiki Link

2006-08-17 Thread Robert S. Grimes

Hi Michael

Try this - it works for me!

   # Even simpler "world's simplest macro"
   def execute(hdf, args, env):
   return 'Hello %s' % (hdf['trac.authname'])

Should produce
   Hello rsg
or whatever your user name is, of course!

-Bob

Michael Bösendorfer wrote:

# bla.py -- The world's simplest macro
def execute(hdf, args, env):
muh = req.authname
return "Hello Michi: called with args: %s" % mu

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-17 Thread Noah Kantrowitz
Sorry, for backwards compatibility the request structure is not passed 
to macros. You can use the hdf trick (hdf['trac.authname']), or you can 
make a new-style plugin.


--Noah

Michael Bösendorfer wrote:

Sorry guys that I'm that stupid but I'm such a newbie so I am not able to get 
the macro run the way I want.
Thanks Noah for your help and I'm sure everybody else would know how to get the 
current user name with req.authname but I played a bit arround and always got 
some error messages.

I tried the following macro and copied it into the wiki-macros folder:

# bla.py -- The world's simplest macro
def execute(hdf, args, env):
muh = req.authname
return "Hello Michi: called with args: %s" % muh

When I call [[bla]] on the wiki page I get the following error message:

Error: Macro bla(None) failed 
global name 'req' is not defined


I think I'm using the wrong parameters. But I don't know how to do different.

Sorry if this is a stupid question but I become really desperate.
If anyone can tell me how to change this little macro and how to call it from 
the wiki site I would be very happy.
 
thanks guys


kind regards
Michael


 Original-Nachricht 
Datum: Wed, 16 Aug 2006 08:44:58 -0400
Von: Noah Kantrowitz <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link


The current user is in req.authname

--Noah

Michael Bösendorfer wrote:

So ... I played a little bit with the writing of macros/plugins and was

successful ;-)

Now I'm trying to get the name of the current logged in user into a

variable but I have no idea how to solve this problem.

I saw that the Trac Database Schema has a table named "session" with

information about user settings, including name, email, and diff options. Can
I use this table to solve the problem or is it useless for my intention? Or
has anybody a better idea?

thanks guys

kind regards
Michael


 Original-Nachricht 
Datum: Wed, 16 Aug 2006 10:30:09 +0200
Von: "Michael Bösendorfer" <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link


Thanks for the replies!
I'm new to writing plugins/macros and so I don't have any idea how to
start writing a macro which can handle the feature I need.
I already read the egg cooking tutorials but I'm not sure if this is

the

right starting point. Would this kind of macro be very complicated? And

how

much time will this take approximately.
Maybe someone can give me some hints how to start writing such a macro!
Thanks a lot and have a nice day!

kind regards
Michael


 Original-Nachricht 
Datum: Thu, 10 Aug 2006 08:43:43 -0400
Von: Noah Kantrowitz <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link


You would need to make a macro to render the link, but yes.

--Noah

Michael Bösendorfer wrote:

Hi guys!

Does anyone know if it is possible to have a link on the wiki page

with

the current logged in user as an argument?

should look like this:
www.blabla.com?user=currentUser

thanks a lot

kind regards
Michael

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac

--


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac




___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-17 Thread Emmanuel Blot

Sorry, the first "from .. import" line is useless (copy n' paste...)

On 8/17/06, Emmanuel Blot <[EMAIL PROTECTED]> wrote:

Importing the code won't give you access to the req (request) instance.
The request object is not available from the macro body.

The authname is also available from the hdf instance.

Michael, you could try something this:

#- Link.py ---
from trac.wiki.formatter import Formatter
import string

def execute(hdf, args, env):
(url, name) = map(string.strip, args.split(','))
return '%s' % (url, hdf['trac.authname'], name)
#-

Example:
[[Link(http://example.com, Example)]]

Of course, you probably need to deal with error cases (authname not
defined when user is not logged in, etc.)

Cheers,
Manu

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-17 Thread Emmanuel Blot

Importing the code won't give you access to the req (request) instance.
The request object is not available from the macro body.

The authname is also available from the hdf instance.

Michael, you could try something this:

#- Link.py ---
from trac.wiki.formatter import Formatter
import string

def execute(hdf, args, env):
   (url, name) = map(string.strip, args.split(','))
   return '%s' % (url, hdf['trac.authname'], name)
#-

Example:
[[Link(http://example.com, Example)]]

Of course, you probably need to deal with error cases (authname not
defined when user is not logged in, etc.)

Cheers,
Manu

On 8/17/06, Günter Dannoritzer <[EMAIL PROTECTED]> wrote:

Michael Bösendorfer wrote:
> Sorry guys that I'm that stupid but I'm such a newbie so I am not able to get 
the macro run the way I want.
> Thanks Noah for your help and I'm sure everybody else would know how to get 
the current user name with req.authname but I played a bit arround and always got 
some error messages.
>
> I tried the following macro and copied it into the wiki-macros folder:
>
> # bla.py -- The world's simplest macro
> def execute(hdf, args, env):
> muh = req.authname
> return "Hello Michi: called with args: %s" % muh
>
> When I call [[bla]] on the wiki page I get the following error message:
>
> Error: Macro bla(None) failed
> global name 'req' is not defined
>

Just looking at the error message from the python code -- without
knowing about macro development for trac -- the instance req is not
defined. You need to import it from somewhere, probably the trac module.

Try adding:

 from trac.core import *

at the top of your file.

I got that from some code snip I found by following the help link of a
trac webpage.


Cheers,

Guenter

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac




--
Manu
___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-17 Thread Günter Dannoritzer
Michael Bösendorfer wrote:
> Sorry guys that I'm that stupid but I'm such a newbie so I am not able to get 
> the macro run the way I want.
> Thanks Noah for your help and I'm sure everybody else would know how to get 
> the current user name with req.authname but I played a bit arround and always 
> got some error messages.
> 
> I tried the following macro and copied it into the wiki-macros folder:
> 
> # bla.py -- The world's simplest macro
> def execute(hdf, args, env):
> muh = req.authname
> return "Hello Michi: called with args: %s" % muh
> 
> When I call [[bla]] on the wiki page I get the following error message:
> 
> Error: Macro bla(None) failed 
> global name 'req' is not defined
> 

Just looking at the error message from the python code -- without
knowing about macro development for trac -- the instance req is not
defined. You need to import it from somewhere, probably the trac module.

Try adding:

 from trac.core import *

at the top of your file.

I got that from some code snip I found by following the help link of a
trac webpage.


Cheers,

Guenter

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-17 Thread Michael Bösendorfer
Sorry guys that I'm that stupid but I'm such a newbie so I am not able to get 
the macro run the way I want.
Thanks Noah for your help and I'm sure everybody else would know how to get the 
current user name with req.authname but I played a bit arround and always got 
some error messages.

I tried the following macro and copied it into the wiki-macros folder:

# bla.py -- The world's simplest macro
def execute(hdf, args, env):
muh = req.authname
return "Hello Michi: called with args: %s" % muh

When I call [[bla]] on the wiki page I get the following error message:

Error: Macro bla(None) failed 
global name 'req' is not defined

I think I'm using the wrong parameters. But I don't know how to do different.

Sorry if this is a stupid question but I become really desperate.
If anyone can tell me how to change this little macro and how to call it from 
the wiki site I would be very happy.
 
thanks guys

kind regards
Michael


 Original-Nachricht 
Datum: Wed, 16 Aug 2006 08:44:58 -0400
Von: Noah Kantrowitz <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link

> The current user is in req.authname
> 
> --Noah
> 
> Michael Bösendorfer wrote:
> > So ... I played a little bit with the writing of macros/plugins and was
> successful ;-)
> > 
> > Now I'm trying to get the name of the current logged in user into a
> variable but I have no idea how to solve this problem.
> > I saw that the Trac Database Schema has a table named "session" with
> information about user settings, including name, email, and diff options. Can
> I use this table to solve the problem or is it useless for my intention? Or
> has anybody a better idea?
> > 
> > thanks guys
> > 
> > kind regards
> > Michael
> > 
> > 
> > -------- Original-Nachricht 
> > Datum: Wed, 16 Aug 2006 10:30:09 +0200
> > Von: "Michael Bösendorfer" <[EMAIL PROTECTED]>
> > An: [email protected]
> > Betreff: Re: [Trac] Wiki Link
> > 
> >> Thanks for the replies!
> >> I'm new to writing plugins/macros and so I don't have any idea how to
> >> start writing a macro which can handle the feature I need.
> >> I already read the egg cooking tutorials but I'm not sure if this is
> the
> >> right starting point. Would this kind of macro be very complicated? And
> how
> >> much time will this take approximately.
> >> Maybe someone can give me some hints how to start writing such a macro!
> >> Thanks a lot and have a nice day!
> >>
> >> kind regards
> >> Michael
> >>
> >>
> >>  Original-Nachricht 
> >> Datum: Thu, 10 Aug 2006 08:43:43 -0400
> >> Von: Noah Kantrowitz <[EMAIL PROTECTED]>
> >> An: [email protected]
> >> Betreff: Re: [Trac] Wiki Link
> >>
> >>> You would need to make a macro to render the link, but yes.
> >>>
> >>> --Noah
> >>>
> >>> Michael Bösendorfer wrote:
> >>>> Hi guys!
> >>>>
> >>>> Does anyone know if it is possible to have a link on the wiki page
> >> with
> >>> the current logged in user as an argument?
> >>>> should look like this:
> >>>> www.blabla.com?user=currentUser
> >>>>
> >>>> thanks a lot
> >>>>
> >>>> kind regards
> >>>> Michael
> >>> ___
> >>> Trac mailing list
> >>> [email protected]
> >>> http://lists.edgewall.com/mailman/listinfo/trac
> >> -- 
> >>
> >>
> >> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> >> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
> >> ___
> >> Trac mailing list
> >> [email protected]
> >> http://lists.edgewall.com/mailman/listinfo/trac
> > 
> 
> ___
> Trac mailing list
> [email protected]
> http://lists.edgewall.com/mailman/listinfo/trac

-- 


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-16 Thread Noah Kantrowitz

The current user is in req.authname

--Noah

Michael Bösendorfer wrote:

So ... I played a little bit with the writing of macros/plugins and was 
successful ;-)

Now I'm trying to get the name of the current logged in user into a variable 
but I have no idea how to solve this problem.
I saw that the Trac Database Schema has a table named "session" with 
information about user settings, including name, email, and diff options. Can I use this 
table to solve the problem or is it useless for my intention? Or has anybody a better 
idea?

thanks guys

kind regards
Michael


 Original-Nachricht 
Datum: Wed, 16 Aug 2006 10:30:09 +0200
Von: "Michael Bösendorfer" <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link


Thanks for the replies!
I'm new to writing plugins/macros and so I don't have any idea how to
start writing a macro which can handle the feature I need.
I already read the egg cooking tutorials but I'm not sure if this is the
right starting point. Would this kind of macro be very complicated? And how
much time will this take approximately.
Maybe someone can give me some hints how to start writing such a macro!
Thanks a lot and have a nice day!

kind regards
Michael


 Original-Nachricht 
Datum: Thu, 10 Aug 2006 08:43:43 -0400
Von: Noah Kantrowitz <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link


You would need to make a macro to render the link, but yes.

--Noah

Michael Bösendorfer wrote:

Hi guys!

Does anyone know if it is possible to have a link on the wiki page

with

the current logged in user as an argument?

should look like this:
www.blabla.com?user=currentUser

thanks a lot

kind regards
Michael

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac

--


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac




___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-16 Thread Michael Bösendorfer
So ... I played a little bit with the writing of macros/plugins and was 
successful ;-)

Now I'm trying to get the name of the current logged in user into a variable 
but I have no idea how to solve this problem.
I saw that the Trac Database Schema has a table named "session" with 
information about user settings, including name, email, and diff options. Can I 
use this table to solve the problem or is it useless for my intention? Or has 
anybody a better idea?

thanks guys

kind regards
Michael


 Original-Nachricht 
Datum: Wed, 16 Aug 2006 10:30:09 +0200
Von: "Michael Bösendorfer" <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link

> Thanks for the replies!
> I'm new to writing plugins/macros and so I don't have any idea how to
> start writing a macro which can handle the feature I need.
> I already read the egg cooking tutorials but I'm not sure if this is the
> right starting point. Would this kind of macro be very complicated? And how
> much time will this take approximately.
> Maybe someone can give me some hints how to start writing such a macro!
> Thanks a lot and have a nice day!
> 
> kind regards
> Michael
> 
> 
>  Original-Nachricht 
> Datum: Thu, 10 Aug 2006 08:43:43 -0400
> Von: Noah Kantrowitz <[EMAIL PROTECTED]>
> An: [email protected]
> Betreff: Re: [Trac] Wiki Link
> 
> > You would need to make a macro to render the link, but yes.
> > 
> > --Noah
> > 
> > Michael Bösendorfer wrote:
> > > Hi guys!
> > > 
> > > Does anyone know if it is possible to have a link on the wiki page
> with
> > the current logged in user as an argument?
> > > should look like this:
> > > www.blabla.com?user=currentUser
> > > 
> > > thanks a lot
> > > 
> > > kind regards
> > > Michael
> > 
> > ___
> > Trac mailing list
> > [email protected]
> > http://lists.edgewall.com/mailman/listinfo/trac
> 
> -- 
> 
> 
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
> ___
> Trac mailing list
> [email protected]
> http://lists.edgewall.com/mailman/listinfo/trac

-- 


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-16 Thread Michael Bösendorfer
Thanks for the replies!
I'm new to writing plugins/macros and so I don't have any idea how to start 
writing a macro which can handle the feature I need.
I already read the egg cooking tutorials but I'm not sure if this is the right 
starting point. Would this kind of macro be very complicated? And how much time 
will this take approximately.
Maybe someone can give me some hints how to start writing such a macro!
Thanks a lot and have a nice day!

kind regards
Michael


 Original-Nachricht 
Datum: Thu, 10 Aug 2006 08:43:43 -0400
Von: Noah Kantrowitz <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: [Trac] Wiki Link

> You would need to make a macro to render the link, but yes.
> 
> --Noah
> 
> Michael Bösendorfer wrote:
> > Hi guys!
> > 
> > Does anyone know if it is possible to have a link on the wiki page with
> the current logged in user as an argument?
> > should look like this:
> > www.blabla.com?user=currentUser
> > 
> > thanks a lot
> > 
> > kind regards
> > Michael
> 
> ___
> Trac mailing list
> [email protected]
> http://lists.edgewall.com/mailman/listinfo/trac

-- 


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-10 Thread Noah Kantrowitz

You would need to make a macro to render the link, but yes.

--Noah

Michael Bösendorfer wrote:

Hi guys!

Does anyone know if it is possible to have a link on the wiki page with the 
current logged in user as an argument?
should look like this:
www.blabla.com?user=currentUser

thanks a lot

kind regards
Michael


___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac


Re: [Trac] Wiki Link

2006-08-10 Thread Matt Good
On Thu, 2006-08-10 at 10:50 +0200, "Michael Bösendorfer" wrote:
> Hi guys!
> 
> Does anyone know if it is possible to have a link on the wiki page
> with the current logged in user as an argument?
> should look like this:
> www.blabla.com?user=currentUser

No, there is not a Wiki syntax for that.

-- 
Matt Good <[EMAIL PROTECTED]>

___
Trac mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac