phundisk
2012-Dec-06 18:17 UTC
[Puppet Users] Proper way to call variables from a parent class to a child class
I currently have a child class of a parent one. The parent defines some variable that I need to use in the child class. I am also using gepetto. Gepetto is complaining about the syntax of the child variable. It is saying that "$parentVar" should be "$::parentVar" however, when changing to what Gepetto wants to use this breaks my classes. Does anyone know the proper method of doing this? Currently the "$parentVar" method below works fine, its just causing an error with Gepetto. class test::parent { $parentVar = "abc" include test::child } class test::child { notify { "The variable is: $parentVar":} } -- _____________________________________________________ This email and any files transmitted with it are confidential and intended solely for the addressee. If you received this email in error, please do not disclose the contents to anyone; kindly notify the sender by return email and delete this email and any attachments from your system. © 2011 Currensee Inc. is a member of the National Futures Association (NFA) Member ID 0403251 | Over the counter retail foreign currency (Forex) trading may involve significant risk of loss. It is not suitable for all investors and you should make sure you understand the risks involved before trading and seek independent advice if necessary. Performance, strategies and charts shown are not necessarily predictive of any particular result and past performance is no indication of future results. Investor returns may vary from Trade Leader returns based on slippage, fees, broker spreads, volatility or other market conditions. Currensee Inc | 54 Canal St 4th Floor | Boston, MA 02114 | +1.617.624.3824 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/0h82g6XX0FoJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Gary Larizza
2012-Dec-06 18:37 UTC
Re: [Puppet Users] Proper way to call variables from a parent class to a child class
Hi there, This is an example of dynamic scoping, and there is a good help document here --> http://docs.puppetlabs.com/guides/scope_and_puppet.html That page should describe what you''re seeing and how to clarify it. On Thu, Dec 6, 2012 at 10:17 AM, phundisk <alex.farhadi@currensee.com>wrote:> I currently have a child class of a parent one. The parent defines > some variable that I need to use in the child class. I am also using > gepetto. Gepetto is complaining about the syntax of the child variable. > It is saying that "$parentVar" should be "$::parentVar" however, when > changing to what Gepetto wants to use this breaks my classes. Does anyone > know the proper method of doing this? Currently the "$parentVar" method > below works fine, its just causing an error with Gepetto. > > class test::parent { > $parentVar = "abc" > include test::child > } > > class test::child { > notify { "The variable is: $parentVar":} > } > > ______________________________**_______________________ > This email and any files transmitted with it are confidential and intended > solely for the addressee. If you received this email in error, please do > not disclose the contents to anyone; kindly notify the sender by return > email and delete this email and any attachments from your system. > > © 2011 Currensee Inc. is a member of the National Futures Association > (NFA) Member ID 0403251 | Over the counter retail foreign currency (Forex) > trading may involve significant risk of loss. It is not suitable for all > investors and you should make sure you understand the risks involved before > trading and seek independent advice if necessary. Performance, strategies > and charts shown are not necessarily predictive of any particular result > and past performance is no indication of future results. Investor returns > may vary from Trade Leader returns based on slippage, fees, broker spreads, > volatility or other market conditions. > > Currensee Inc | 54 Canal St 4th Floor | Boston, MA 02114 | +1.617.624.3824 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/0h82g6XX0FoJ. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- Gary Larizza Professional Services Engineer Puppet Labs -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
phundisk
2012-Dec-07 22:17 UTC
Re: [Puppet Users] Proper way to call variables from a parent class to a child class
Understandable, thank you for that clarification. The issue I am facing comes when I am using a define and I need to call that custom variable set in another class that calls the define. Please see the example below. Though this works as I want it to below, I am getting a syntax error. If I chang the variable in class test to "$test::define::defVar", breaks what I want it to do. Am I breaking some style guidelines in doing what I want to do? Is there another way I can call this defined variable without producing a syntax error? class test { notify {"!!!!!!!!!!!!!!!!!!!The variable inside test main class is $defVar":} } define test::define($defVar=''defVar''){ include test notify {"the variable in define define is: $defVar":} } class test::stuff::test1{ test::define {''test1'': defVar => ''NEWDEFVAR''} } On Thursday, December 6, 2012 1:37:54 PM UTC-5, Gary Larizza wrote:> > Hi there, > > This is an example of dynamic scoping, and there is a good help document > here --> http://docs.puppetlabs.com/guides/scope_and_puppet.html That > page should describe what you''re seeing and how to clarify it. > > > On Thu, Dec 6, 2012 at 10:17 AM, phundisk <alex.f...@currensee.com<javascript:> > > wrote: > >> I currently have a child class of a parent one. The parent defines >> some variable that I need to use in the child class. I am also using >> gepetto. Gepetto is complaining about the syntax of the child variable. >> It is saying that "$parentVar" should be "$::parentVar" however, when >> changing to what Gepetto wants to use this breaks my classes. Does anyone >> know the proper method of doing this? Currently the "$parentVar" method >> below works fine, its just causing an error with Gepetto. >> >> class test::parent { >> $parentVar = "abc" >> include test::child >> } >> >> class test::child { >> notify { "The variable is: $parentVar":} >> } >> >> ______________________________**_______________________ >> This email and any files transmitted with it are confidential and >> intended solely for the addressee. If you received this email in error, >> please do not disclose the contents to anyone; kindly notify the sender by >> return email and delete this email and any attachments from your system. >> >> © 2011 Currensee Inc. is a member of the National Futures Association >> (NFA) Member ID 0403251 | Over the counter retail foreign currency (Forex) >> trading may involve significant risk of loss. It is not suitable for all >> investors and you should make sure you understand the risks involved before >> trading and seek independent advice if necessary. Performance, strategies >> and charts shown are not necessarily predictive of any particular result >> and past performance is no indication of future results. Investor returns >> may vary from Trade Leader returns based on slippage, fees, broker spreads, >> volatility or other market conditions. >> >> Currensee Inc | 54 Canal St 4th Floor | Boston, MA 02114 | >> +1.617.624.3824 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/puppet-users/-/0h82g6XX0FoJ. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> puppet-users...@googlegroups.com <javascript:>. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> > > > > -- > > Gary Larizza > Professional Services Engineer > Puppet Labs >-- _____________________________________________________ This email and any files transmitted with it are confidential and intended solely for the addressee. If you received this email in error, please do not disclose the contents to anyone; kindly notify the sender by return email and delete this email and any attachments from your system. © 2011 Currensee Inc. is a member of the National Futures Association (NFA) Member ID 0403251 | Over the counter retail foreign currency (Forex) trading may involve significant risk of loss. It is not suitable for all investors and you should make sure you understand the risks involved before trading and seek independent advice if necessary. Performance, strategies and charts shown are not necessarily predictive of any particular result and past performance is no indication of future results. Investor returns may vary from Trade Leader returns based on slippage, fees, broker spreads, volatility or other market conditions. Currensee Inc | 54 Canal St 4th Floor | Boston, MA 02114 | +1.617.624.3824 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/_StIo1B13SEJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Gary Larizza
2012-Dec-07 22:24 UTC
Re: [Puppet Users] Proper way to call variables from a parent class to a child class
On Fri, Dec 7, 2012 at 2:17 PM, phundisk <alex.farhadi@currensee.com> wrote:> Understandable, thank you for that clarification. The issue I am facing > comes when I am using a define and I need to call that custom variable set > in another class that calls the define. Please see the example below. > Though this works as I want it to below, I am getting a syntax error. If > I chang the variable in class test to "$test::define::defVar", breaks what > I want it to do. Am I breaking some style guidelines in doing what I want > to do? Is there another way I can call this defined variable without > producing a syntax error? > > class test { > notify {"!!!!!!!!!!!!!!!!!!!The variable inside test main class is > $defVar":} > } > > define test::define($defVar=''defVar''){ > include test > notify {"the variable in define define is: $defVar":} >In this case, using $defVar inside test::define is completely fine because it''s defined in the scope of this defined resource type ($defVar is in the parameter declaration section of the defined resource type, which makes it local, in scope, to this defined resource type). Even though the class class test::stuff::test1 is declaring a new resource of type test::define, it''s passing a value (''NEWDEFVAR'') which will get set INSIDE the scope of test::define as $defVar. I hope that made sense and helped you; it can become a complicated issue quickly :)> } > > class test::stuff::test1{ > test::define {''test1'': defVar => ''NEWDEFVAR''} > } > > > > > > > > > > On Thursday, December 6, 2012 1:37:54 PM UTC-5, Gary Larizza wrote: > >> Hi there, >> >> This is an example of dynamic scoping, and there is a good help document >> here --> http://docs.puppetlabs.**com/guides/scope_and_puppet.**html<http://docs.puppetlabs.com/guides/scope_and_puppet.html> That page should describe what you''re seeing and how to clarify it. >> >> >> On Thu, Dec 6, 2012 at 10:17 AM, phundisk <alex.f...@currensee.com>wrote: >> >>> I currently have a child class of a parent one. The parent defines >>> some variable that I need to use in the child class. I am also using >>> gepetto. Gepetto is complaining about the syntax of the child variable. >>> It is saying that "$parentVar" should be "$::parentVar" however, when >>> changing to what Gepetto wants to use this breaks my classes. Does anyone >>> know the proper method of doing this? Currently the "$parentVar" method >>> below works fine, its just causing an error with Gepetto. >>> >>> class test::parent { >>> $parentVar = "abc" >>> include test::child >>> } >>> >>> class test::child { >>> notify { "The variable is: $parentVar":} >>> } >>> >>> ______________________________****_______________________ >>> This email and any files transmitted with it are confidential and >>> intended solely for the addressee. If you received this email in error, >>> please do not disclose the contents to anyone; kindly notify the sender by >>> return email and delete this email and any attachments from your system. >>> >>> © 2011 Currensee Inc. is a member of the National Futures Association >>> (NFA) Member ID 0403251 | Over the counter retail foreign currency (Forex) >>> trading may involve significant risk of loss. It is not suitable for all >>> investors and you should make sure you understand the risks involved before >>> trading and seek independent advice if necessary. Performance, strategies >>> and charts shown are not necessarily predictive of any particular result >>> and past performance is no indication of future results. Investor returns >>> may vary from Trade Leader returns based on slippage, fees, broker spreads, >>> volatility or other market conditions. >>> >>> Currensee Inc | 54 Canal St 4th Floor | Boston, MA 02114 | >>> +1.617.624.3824 >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Puppet Users" group. >>> To view this discussion on the web visit https://groups.google.com/d/** >>> msg/puppet-users/-/**0h82g6XX0FoJ<https://groups.google.com/d/msg/puppet-users/-/0h82g6XX0FoJ> >>> . >>> To post to this group, send email to puppet...@googlegroups.com. >>> To unsubscribe from this group, send email to puppet-users...@** >>> googlegroups.com. >>> >>> For more options, visit this group at http://groups.google.com/** >>> group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>> . >>> >> >> >> >> -- >> >> Gary Larizza >> Professional Services Engineer >> Puppet Labs >> > > ______________________________**_______________________ > This email and any files transmitted with it are confidential and intended > solely for the addressee. If you received this email in error, please do > not disclose the contents to anyone; kindly notify the sender by return > email and delete this email and any attachments from your system. > > © 2011 Currensee Inc. is a member of the National Futures Association > (NFA) Member ID 0403251 | Over the counter retail foreign currency (Forex) > trading may involve significant risk of loss. It is not suitable for all > investors and you should make sure you understand the risks involved before > trading and seek independent advice if necessary. Performance, strategies > and charts shown are not necessarily predictive of any particular result > and past performance is no indication of future results. Investor returns > may vary from Trade Leader returns based on slippage, fees, broker spreads, > volatility or other market conditions. > > Currensee Inc | 54 Canal St 4th Floor | Boston, MA 02114 | +1.617.624.3824 > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/_StIo1B13SEJ. > > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- Gary Larizza Professional Services Engineer Puppet Labs -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.